Apache log4cxx
Version 0.13.0
|
When rolling over, FixedWindowRollingPolicy
renames files according to a fixed window algorithm as described below.
More...
#include <fixedwindowrollingpolicy.h>
Public Member Functions | |||||||||
FixedWindowRollingPolicy () | |||||||||
void | activateOptions (log4cxx::helpers::Pool &p) | ||||||||
Activate the options that were previously set with calls to option setters. More... | |||||||||
void | setOption (const LogString &option, const LogString &value) | ||||||||
Set option to value . More... | |||||||||
void | rollover () | ||||||||
int | getMaxIndex () const | ||||||||
int | getMinIndex () const | ||||||||
void | setMaxIndex (int newVal) | ||||||||
void | setMinIndex (int newVal) | ||||||||
RolloverDescriptionPtr | initialize (const LogString ¤tActiveFile, const bool append, log4cxx::helpers::Pool &pool) | ||||||||
Initialize the policy and return any initial actions for rolling file appender.
| |||||||||
RolloverDescriptionPtr | rollover (const LogString ¤tActiveFile, const bool append, log4cxx::helpers::Pool &pool) | ||||||||
Prepare for a rollover.This method is called prior to closing the active log file, performs any necessary preliminary actions and describes actions needed after close of current log file.
| |||||||||
Public Member Functions inherited from log4cxx::rolling::RollingPolicyBase | |||||||||
RollingPolicyBase () | |||||||||
virtual | ~RollingPolicyBase () | ||||||||
void | setFileNamePattern (const LogString &fnp) | ||||||||
Set file name pattern. More... | |||||||||
LogString | getFileNamePattern () const | ||||||||
Get file name pattern. More... | |||||||||
bool | getCreateIntermediateDirectories () const | ||||||||
void | setCreateIntermediateDirectories (bool createIntermediate) | ||||||||
Public Member Functions inherited from log4cxx::rolling::RollingPolicy | |||||||||
virtual | ~RollingPolicy () | ||||||||
Public Member Functions inherited from log4cxx::spi::OptionHandler | |||||||||
virtual | ~OptionHandler () | ||||||||
Public Member Functions inherited from log4cxx::helpers::Object | |||||||||
virtual | ~Object () | ||||||||
virtual bool | instanceof (const Class &clazz) const =0 | ||||||||
virtual const void * | cast (const Class &clazz) const =0 | ||||||||
Protected Member Functions | |
log4cxx::pattern::PatternMap | getFormatSpecifiers () const |
Protected Member Functions inherited from log4cxx::rolling::RollingPolicyBase | |
void | parseFileNamePattern () |
Parse file name pattern. More... | |
void | formatFileName (log4cxx::helpers::ObjectPtr &obj, LogString &buf, log4cxx::helpers::Pool &p) const |
Format file name. More... | |
log4cxx::pattern::PatternConverterPtr | getIntegerPatternConverter () const |
log4cxx::pattern::PatternConverterPtr | getDatePatternConverter () const |
When rolling over, FixedWindowRollingPolicy
renames files according to a fixed window algorithm as described below.
The ActiveFileName property, which is required, represents the name of the file where current logging output will be written. The FileNamePattern option represents the file name pattern for the archived (rolled over) log files. If present, the FileNamePattern option must include an integer token, that is the string "%i" somwhere within the pattern.
Let max and min represent the values of respectively the MaxIndex and MinIndex options. Let "foo.log" be the value of the ActiveFile option and "foo.%i.log" the value of FileNamePattern. Then, when rolling over, the file foo.max.log
will be deleted, the file foo.max-1.log
will be renamed as foo.max.log
, the file foo.max-2.log
renamed as foo.max-1.log
, and so on, the file foo.min+1.log
renamed as foo.min+2.log
. Lastly, the active file foo.log
will be renamed as foo.min.log
and a new active file name foo.log
will be created.
Given that this rollover algorithm requires as many file renaming operations as the window size, large window sizes are discouraged. The current implementation will automatically reduce the window size to 12 when larger values are specified by the user.
log4cxx::rolling::FixedWindowRollingPolicy::FixedWindowRollingPolicy | ( | ) |
|
virtual |
Activate the options that were previously set with calls to option setters.
This allows to defer activiation of the options until all options have been set. This is required for components which have related options that remain ambigous until all are set.
For example, the FileAppender has the File and Append options both of which are ambigous until the other is also set.
Implements log4cxx::rolling::RollingPolicyBase.
|
protectedvirtual |
Implements log4cxx::rolling::RollingPolicyBase.
int log4cxx::rolling::FixedWindowRollingPolicy::getMaxIndex | ( | ) | const |
int log4cxx::rolling::FixedWindowRollingPolicy::getMinIndex | ( | ) | const |
|
virtual |
Initialize the policy and return any initial actions for rolling file appender.
currentActiveFile | current value of RollingFileAppender.getFile(). |
append | current value of RollingFileAppender.getAppend(). |
pool | pool for memory allocations during call. |
SecurityException | if denied access to log files. |
Implements log4cxx::rolling::RollingPolicy.
void log4cxx::rolling::FixedWindowRollingPolicy::rollover | ( | ) |
|
virtual |
Prepare for a rollover.This method is called prior to closing the active log file, performs any necessary preliminary actions and describes actions needed after close of current log file.
currentActiveFile | file name for current active log file. |
append | current value of the parent FileAppender.getAppend(). |
pool | pool for memory allocations during call. |
SecurityException | if denied access to log files. |
Implements log4cxx::rolling::RollingPolicy.
void log4cxx::rolling::FixedWindowRollingPolicy::setMaxIndex | ( | int | newVal | ) |
void log4cxx::rolling::FixedWindowRollingPolicy::setMinIndex | ( | int | newVal | ) |
|
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 log4cxx::rolling::RollingPolicyBase.