FixedWindowRollingPolicy Class Reference

When rolling over, FixedWindowRollingPolicy renames files according to a fixed window algorithm as described below. More...

Inherits log4cxx::rolling::RollingPolicyBase.

List of all members.

Classes

class  ClazzFixedWindowRollingPolicy

Public Types

enum  { MAX_WINDOW_SIZE = 12 }
 

It's almost always a bad idea to have a large window size, say over 12.

More...

Public Member Functions

virtual const helpers::ClassgetClass () const
const void * cast (const helpers::Class &clazz) const
bool instanceof (const helpers::Class &clazz) const
bool purge (int purgeStart, int maxIndex, log4cxx::helpers::Pool &p) const
 FixedWindowRollingPolicy ()
void activateOptions (log4cxx::helpers::Pool &p)
 Activate the options that were previously set with calls to option setters.
void setOption (const LogString &option, const LogString &value)
 Set option to value.
void rollover ()
int getMaxIndex () const
int getMinIndex () const
void setMaxIndex (int newVal)
void setMinIndex (int newVal)
virtual RolloverDescriptionPtr initialize (const LogString &file, const bool append, log4cxx::helpers::Pool &p)
 Initialize the policy and return any initial actions for rolling file appender.
virtual RolloverDescriptionPtr rollover (const LogString &activeFile, log4cxx::helpers::Pool &p)
 Prepare for a rollover.

Static Public Member Functions

static const helpers::ClassgetStaticClass ()
static const
log4cxx::helpers::ClassRegistration
registerClass ()

Public Attributes

int minIndex
int maxIndex
bool explicitActiveFile

Protected Member Functions

log4cxx::pattern::PatternMap getFormatSpecifiers () const

Detailed Description

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.


Member Enumeration Documentation

anonymous enum

It's almost always a bad idea to have a large window size, say over 12.

Enumerator:
MAX_WINDOW_SIZE 

Constructor & Destructor Documentation


Member Function Documentation

void activateOptions ( log4cxx::helpers::Pool p  )  [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 RollingPolicyBase.

const void* cast ( const helpers::Class clazz  )  const [inline, virtual]

Reimplemented from RollingPolicyBase.

virtual const helpers::Class& getClass (  )  const [virtual]

Reimplemented from RollingPolicyBase.

log4cxx::pattern::PatternMap getFormatSpecifiers (  )  const [protected, virtual]

Implements RollingPolicyBase.

int getMaxIndex (  )  const
int getMinIndex (  )  const
static const helpers::Class& getStaticClass (  )  [static]

Reimplemented from RollingPolicyBase.

virtual RolloverDescriptionPtr initialize ( const LogString file,
const bool  append,
log4cxx::helpers::Pool p 
) [virtual]

Initialize the policy and return any initial actions for rolling file appender.

Parameters:
file current value of RollingFileAppender::getFile().
append current value of RollingFileAppender::getAppend().
p pool used for any required memory allocations.
Returns:
Description of the initialization, may be null to indicate no initialization needed.
Exceptions:
SecurityException if denied access to log files.

Implements RollingPolicy.

bool instanceof ( const helpers::Class clazz  )  const [inline, virtual]

Reimplemented from RollingPolicyBase.

bool purge ( int  purgeStart,
int  maxIndex,
log4cxx::helpers::Pool p 
) const
static const log4cxx::helpers::ClassRegistration& registerClass (  )  [static]

Reimplemented from RollingPolicyBase.

virtual RolloverDescriptionPtr rollover ( const LogString activeFile,
log4cxx::helpers::Pool p 
) [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.

Parameters:
activeFile file name for current active log file.
p pool used for any required memory allocations.
Returns:
Description of pending rollover, may be null to indicate no rollover at this time.
Exceptions:
SecurityException if denied access to log files.

Implements RollingPolicy.

void rollover (  ) 
void setMaxIndex ( int  newVal  ) 
void setMinIndex ( int  newVal  ) 
void setOption ( const LogString option,
const LogString 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 RollingPolicyBase.


Member Data Documentation

int maxIndex
int minIndex

The documentation for this class was generated from the following file: