Difference between revisions of "TYPO3/Change logging"

From Aimeos documentation

< TYPO3
 
Line 1: Line 1:
 
You can change logging from the database to another target in  ''ext_localconf.php'', e.g.:
 
You can change logging from the database to another target in  ''ext_localconf.php'', e.g.:
  
  $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_context_logger']`= function( $context ) {
+
  $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_context_logger'] = function( $context ) {
     return $context->setLogger( new \Aimeos\MW\Logger\File( '/path/to/file', <loglevel>, [<facility>] );
+
     return $context->setLogger( new \Aimeos\MW\Logger\File( '/path/to/file', <loglevel>, [<facility>] ) );
 
  }
 
  }
  

Latest revision as of 10:49, 5 November 2019

You can change logging from the database to another target in ext_localconf.php, e.g.:

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_context_logger'] = function( $context ) {
    return $context->setLogger( new \Aimeos\MW\Logger\File( '/path/to/file', <loglevel>, [<facility>] ) );
}

The loglevel parameter is the minium level for which messages get logged, e.g. a log level of "3" logs all "error", "critical" and "alert" and "emergency" messages. The available log levels are:

  • 0: Emergency
  • 1: Alert
  • 2: Critical
  • 3: Error
  • 4: Warning
  • 5: Notice
  • 6: Info
  • 7: Debug

The "facility" parameter limits the log messages to the list of given facilities, the names of the sources of the log messages, e.g. "core/sql". If no paramter or null is passed, all error messages are logged.

The available logger implementations are:

  • File( $filename, $priority = \Aimeos\MW\Logger\Base::ERR, array $facilities = null )
  • Errorlog( $loglevel = \Aimeos\MW\Logger\Base::ERR, array $facilities = null )
  • Compose( array $loggers )

The Compose logger can send log messages to different loggers, e.g. to the File logger and a self written logger:

new \Aimeos\MW\Logger\Compose( [
    new \Aimeos\MW\Logger\File( '/path/to/file' ),
    new \Aimeos\MW\Logger\MySmsLogger( '<number>', 2 ),
] );

This would log all error/critical/alert/emergency messages to the given file and send a SMS for all critical/alert/emergency messages.