LogManager enables an auto-configured usage of loggers in your PHP code
by reading the logging configuration and setting the minimum severity level of the Logger
/** @var $logger \TYPO3\CMS\Core\Log\Logger */ $logger = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Core\Log\LogManager')->getLogger(__CLASS__);
__CLASS__ as name for the logger is recommended to enable logging configuration
based on the class hierarchy.
\TYPO3\CMS\Core\Log\Logger provides a central point for submitting log messages,
$logger->log($level, $message, $data);
which takes three parameters:
One of either:
|$message||Type string||The log message itself.|
|$data||Type array||Optional parameter, can contain additional data, which is added to the log record in the form of an array.|
An early return in the
log() method prevents unneeded computation work to be done.
So you are safe to call
$logger->debug() frequently without slowing down your code too much.
The Logger will know by its configuration, what the most explicit severity level is.
As next step, all registered Processors are notified. They can modify the log records or add extra information.
The Logger then forwards the log records to all of its configured Writers, which will then persist the log record.
For each of the severity levels mentioned above, a shorthand method exists in
$logger->debug($message, array $data = array());
$logger->info($message, array $data = array());
$logger->notice($message, array $data = array());