Attention

TYPO3 v7 has reached its end-of-life November 30th, 2018 and is not maintained by the community anymore. Looking for a stable version? Use the version switch on the top left.

There is no further ELTS support. It is recommended that you upgrade your project and use a supported version of TYPO3.

Logging with TYPO3

TYPO3 Logging consists of the following components:

  • A Logger that receives the log message and related details, like a severity

  • A LogRecord model which encapsulates the data

  • Configuration of the logging system

  • Writers which write the log records to different targets (like file, database, rsyslog server, etc.)

  • Processors which add more detailed information to the log record.

Quick Usage

Instantiate a logger for the current class:

/** @var $logger \TYPO3\CMS\Core\Log\Logger */
$logger = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Core\Log\LogManager')->getLogger(__CLASS__);

Log a simple message:

$logger->info('Everything went fine.');
$logger->warning('Something went awry, check your configuration!');

Provide additional information with the log message:

$logger->error(
  'This was not a good idea',
  array(
    'foo' => $bar,
    'bar' => $foo,
  )
);

$logger->warning() etc. are only shorthands - you can also call $logger->log() directly and pass the severity level:

$logger->log(
     \TYPO3\CMS\Core\Log\LogLevel::CRITICAL,
     'This is an utter failure!'
);

By default the log entries are written to file typo3temp/logs/typo3.log. A sample output looks like this:

Fri, 08 Mar 2013 09:45:00 +0100 [INFO] request="5139a50bee3a1" component="TYPO3.Examples.Controller.DefaultController": Everything went fine.
Fri, 08 Mar 2013 09:45:00 +0100 [WARNING] request="5139a50bee3a1" component="TYPO3.Examples.Controller.DefaultController": Something went awry, check your configuration!
Fri, 08 Mar 2013 09:45:00 +0100 [ERROR] request="5139a50bee3a1" component="TYPO3.Examples.Controller.DefaultController": This was not a good idea - {"foo":"bar","bar":{}}
Fri, 08 Mar 2013 09:45:00 +0100 [CRITICAL] request="5139a50bee3a1" component="TYPO3.Examples.Controller.DefaultController": This is an utter failure!