Public Member Functions | |
RollingFileAppender () | |
RollingFileAppender (const LayoutPtr &layout, const String &fileName, bool append) | |
RollingFileAppender (const LayoutPtr &layout, const String &fileName) | |
int | getMaxBackupIndex () const |
long | getMaximumFileSize () const |
void | rollOver () |
void | setMaxBackupIndex (int maxBackupIndex) |
void | setMaxFileSize (const String &value) |
virtual void | setOption (const String &option, const String &value) |
Protected Member Functions | |
virtual void | subAppend (const spi::LoggingEventPtr &event) |
Protected Attributes | |
long | maxFileSize |
int | maxBackupIndex |
The default constructor simply calls its parents constructor.
RollingFileAppender | ( | const LayoutPtr & | layout, | |
const String & | fileName, | |||
bool | append | |||
) |
Instantiate a RollingFileAppender and open the file designated by filename
. The opened filename will become the ouput destination for this appender.
If the append
parameter is true, the file will be appended to. Otherwise, the file desginated by filename
will be truncated before being opened.
RollingFileAppender | ( | const LayoutPtr & | layout, | |
const String & | fileName | |||
) |
Instantiate a FileAppender and open the file designated by filename
. The opened filename will become the output destination for this appender.
The file will be appended to.
int getMaxBackupIndex | ( | ) | const [inline] |
Returns the value of the MaxBackupIndex option.
long getMaximumFileSize | ( | ) | const [inline] |
Get the maximum size that the output file is allowed to reach before being rolled over to backup files.
void rollOver | ( | ) |
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.
void setMaxBackupIndex | ( | int | maxBackupIndex | ) | [inline] |
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
.
void setMaxFileSize | ( | const String & | value | ) | [inline] |
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.
void setOption | ( | const String & | option, | |
const String & | value | |||
) | [virtual] |
Set option
to value
.
The handling of each option depends on the OptionHandler instance. Some options may become active immediately whereas other may be activated only when activateOptions is called.
Reimplemented from FileAppender.
void subAppend | ( | const spi::LoggingEventPtr & | event | ) | [protected, virtual] |
This method differentiates RollingFileAppender from its parent class.
Reimplemented from WriterAppender.
long maxFileSize [protected] |
The default maximum file size is 10MB.
int maxBackupIndex [protected] |
There is one backup file by default.