LoggerAppenderRollingFileLoggerAppenderRollingFile writes logging events to a specified file. The file is rolled over after a specified size has been reached. For example, if logging to a file named file.log, when the file size reaches the specified size limit, the contents are archived in a file named file.log.1 and file.log is truncated. When the size limit is reached the second time, file.log.1 is renamed to file.log.2; contents from file.log are archived to file.log.1 and file.log is truncated This continues until the maximum backup index is reached, after which the oldest log file is deleted on each rollover. LayoutThis appender requires a layout. If no layout is specified in configuration, LoggerLayoutSimple will be used by default. ParametersThe following parameters are available:
ExamplesThis example shows how to configure LoggerAppenderRollingFile to rollover after reaching the size of 1MB and for keeping the last 5 backup files.
<configuration xmlns="http://logging.apache.org/log4php/"> <appender name="default" class="LoggerAppenderRollingFile"> <layout class="LoggerLayoutSimple" /> <param name="file" value="file.log" /> <param name="maxFileSize" value="1MB" /> <param name="maxBackupIndex" value="5" /> </appender> <root> <appender_ref ref="default" /> </root> </configuration> array( 'appenders' => array( 'default' => array( 'class' => 'LoggerAppenderRollingFile', 'layout' => array( 'class' => 'LoggerLayoutSimple', ), 'params' => array( 'file' => 'file.log', 'maxFileSize' => '1MB', 'maxBackupIndex' => 5, ), ), ), 'rootLogger' => array( 'appenders' => array('default'), ), ); |