Class LoggerAppenderRollingFile

Description

LoggerAppenderRollingFile extends LoggerAppenderFile to backup the log files when they reach a certain size.

This appender uses a layout.

Parameters are:

  • file - The target file to write to
  • filename - The target file to write to (deprecated, use "file" instead).
  • append - Sets if the appender should append to the end of the file or overwrite content ("true" or "false")
  • maxBackupIndex - Set the maximum number of backup files to keep around (int)
  • maxFileSize - Set the maximum size that the output file is allowed to reach before being rolled over to backup files. Suffixes like "KB", "MB" or "GB" are allowed, f. e. "10KB" is interpreted as 10240
  • maximumFileSize - Alias to maxFileSize (deprecated, use "maxFileSize" instead)
<p>Contributors: Sergio Strampelli.</p>

An example:

  1. require_once dirname(__FILE__).'/../../main/php/Logger.php';
  2.  
  3. Logger::configure(dirname(__FILE__).'/../resources/appender_socket.properties');
  4. $logger Logger::getRootLogger();
  5. $logger->fatal("Hello World!");

  1. log4php.appender.default = LoggerAppenderSocket
  2. log4php.appender.default.layout = LoggerLayoutSimple
  3. log4php.appender.default.remoteHost = localhost
  4. log4php.appender.default.port = 4242
  5. log4php.appender.default.useXml = true
  6. log4php.appender.default.locationInfo = false
  7. log4php.rootLogger = DEBUG, default

  • version: $Revision: 1213283 $

Located in /appenders/LoggerAppenderRollingFile.php (line 49)

LoggerConfigurable
   |
   --LoggerAppender
      |
      --LoggerAppenderFile
         |
         --LoggerAppenderRollingFile
Variable Summary
Method Summary
void append (LoggerLoggingEvent $event)
integer getExpandedFileName ()
Returns getMaxBackupIndex ()
Returns getMaxFileSize ()
integer getMaximumFileSize ()
void rollOver ()
void setFile ( $fileName)
void setMaxBackupIndex (mixed $maxBackups)
the setMaxFileSize (mixed $value)
void setMaximumFileSize (mixed $maxFileSize)
Variables
string $expandedFileName = null (line 86)
  • var: the filename expanded
  • access: private
integer $maxBackupIndex = 1 (line 81)

Set the maximum number of backup files to keep around.

The MaxBackupIndex option determines how many backup files are kept before the oldest is erased. This option takes a positive integer value. If set to zero, then there will be no backup files and the log file will be truncated when it reaches MaxFileSize.

There is one backup file by default.

  • access: protected
integer $maxFileSize = 10485760 (line 67)

Set the maximum size that the output file is allowed to reach before being rolled over to backup files.

In configuration files, the MaxFileSize option takes a long integer in the range 0 - 2^63. You can specify the value with the suffixes "KB", "MB" or "GB" so that the integer is interpreted being expressed respectively in kilobytes, megabytes or gigabytes. For example, the value "10KB" will be interpreted as 10240.

The default maximum file size is 10MB.

Note that MaxFileSize cannot exceed 2 GB.

  • access: protected

Inherited Variables

Inherited from LoggerAppenderFile

LoggerAppenderFile::$append
LoggerAppenderFile::$file
LoggerAppenderFile::$fp

Inherited from LoggerAppender

LoggerAppender::$closed
LoggerAppender::$filter
LoggerAppender::$layout
LoggerAppender::$name
LoggerAppender::$requiresLayout
LoggerAppender::$threshold
Methods
append (line 197)
  • access: public
void append (LoggerLoggingEvent $event)

Redefinition of:
LoggerAppenderFile::append()
getExpandedFileName (line 92)

Returns the value of the MaxBackupIndex option.

  • access: private
integer getExpandedFileName ()
getMaxBackupIndex (line 220)
  • return: the maximum number of backup files to keep around.
  • access: public
Returns getMaxBackupIndex ()
getMaxFileSize (line 228)
  • return: the maximum size that the output file is allowed to reach before being rolled over to backup files.
  • access: public
Returns getMaxFileSize ()
getMaximumFileSize (line 101)

Get the maximum size that the output file is allowed to reach before being rolled over to backup files.

  • access: public
integer getMaximumFileSize ()
rollOver (line 115)

Implements the usual roll over behaviour.

If MaxBackupIndex is positive, then files File.1, ..., File.MaxBackupIndex -1 are renamed to File.2, ..., File.MaxBackupIndex. Moreover, File is renamed File.1 and closed. A new File is created to receive further log output.

If MaxBackupIndex is equal to zero, then the File is truncated with no backup files created. Rollover must be called while the file is locked so that it is safe for concurrent access.

  • access: private
void rollOver ()
setFile (line 143)
  • access: public
void setFile ( $fileName)
  • $fileName

Redefinition of:
LoggerAppenderFile::setFile()
Sets the file where the log output will go.
setMaxBackupIndex (line 164)

Set the maximum number of backup files to keep around.

The MaxBackupIndex option determines how many backup files are kept before the oldest is erased. This option takes a positive integer value. If set to zero, then there will be no backup files and the log file will be truncated when it reaches MaxFileSize.

  • access: public
void setMaxBackupIndex (mixed $maxBackups)
  • mixed $maxBackups
setMaxFileSize (line 193)

Set the maximum size that the output file is allowed to reach before being rolled over to backup files.

In configuration files, the maxFileSize option takes an long integer in the range 0 - 2^63. You can specify the value with the suffixes "KB", "MB" or "GB" so that the integer is interpreted being expressed respectively in kilobytes, megabytes or gigabytes. For example, the value "10KB" will be interpreted as 10240.

  • return: actual file size set
  • access: public
the setMaxFileSize (mixed $value)
  • mixed $value
setMaximumFileSize (line 176)

Set the maximum size that the output file is allowed to reach before being rolled over to backup files.

void setMaximumFileSize (mixed $maxFileSize)
  • mixed $maxFileSize

Inherited Methods

Inherited From LoggerAppenderFile

LoggerAppenderFile::activateOptions()
LoggerAppenderFile::append()
LoggerAppenderFile::close()
LoggerAppenderFile::getAppend()
LoggerAppenderFile::getFile()
LoggerAppenderFile::getFileName()
LoggerAppenderFile::setAppend()
LoggerAppenderFile::setFile()
LoggerAppenderFile::setFileName()

Inherited From LoggerAppender

LoggerAppender::__construct()
LoggerAppender::activateOptions()
LoggerAppender::addFilter()
LoggerAppender::append()
LoggerAppender::clearFilters()
LoggerAppender::close()
LoggerAppender::doAppend()
LoggerAppender::getDefaultLayout()
LoggerAppender::getFilter()
LoggerAppender::getFirstFilter()
LoggerAppender::getLayout()
LoggerAppender::getName()
LoggerAppender::getThreshold()
LoggerAppender::isAsSevereAsThreshold()
LoggerAppender::requiresLayout()
LoggerAppender::setLayout()
LoggerAppender::setName()
LoggerAppender::setThreshold()
LoggerAppender::warn()

Inherited From LoggerConfigurable

LoggerConfigurable::setBoolean()
LoggerConfigurable::setFileSize()
LoggerConfigurable::setInteger()
LoggerConfigurable::setLevel()
LoggerConfigurable::setNumeric()
LoggerConfigurable::setPositiveInteger()
LoggerConfigurable::setString()
LoggerConfigurable::warn()

Documentation generated on Sat, 18 Feb 2012 22:32:23 +0000 by phpDocumentor 1.4.3