Log4j 1.3alpha-6

org.apache.log4j.rolling
Class FixedWindowRollingPolicy

java.lang.Object
  |
  +--org.apache.log4j.spi.ComponentBase
        |
        +--org.apache.log4j.rolling.RollingPolicyBase
              |
              +--org.apache.log4j.rolling.FixedWindowRollingPolicy
All Implemented Interfaces:
Component, OptionHandler, RollingPolicy

public class FixedWindowRollingPolicy
extends RollingPolicyBase

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" somewhere 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.

Since:
1.3
Author:
Ceki Gülcü

Field Summary
 
Fields inherited from class org.apache.log4j.rolling.RollingPolicyBase
activeFileName, compressionMode, fileNamePattern, fileNamePatternStr
 
Fields inherited from class org.apache.log4j.spi.ComponentBase
repository
 
Constructor Summary
FixedWindowRollingPolicy()
           
 
Method Summary
 void activateOptions()
          Activate the options that were previously set with calls to option setters.
 java.lang.String getActiveFileName()
          Return the value of the ActiveFile option.
 int getMaxIndex()
           
 int getMinIndex()
           
 void rollover()
          Rolls over log files according to implementation policy.
 void setMaxIndex(int maxIndex)
           
 void setMinIndex(int minIndex)
           
 
Methods inherited from class org.apache.log4j.rolling.RollingPolicyBase
determineCompressionMode, getFileNamePattern, setActiveFileName, setFileNamePattern
 
Methods inherited from class org.apache.log4j.spi.ComponentBase
getLogger, setLoggerRepository
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FixedWindowRollingPolicy

public FixedWindowRollingPolicy()
Method Detail

activateOptions

public void activateOptions()
Description copied from interface: OptionHandler
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.

Specified by:
activateOptions in interface OptionHandler
Specified by:
activateOptions in class RollingPolicyBase

rollover

public void rollover()
              throws RolloverFailure
Description copied from interface: RollingPolicy
Rolls over log files according to implementation policy.

This method is invoked by RollingFileAppender, usually at the behest of its TriggeringPolicy.

Throws:
RolloverFailure - Thrown if the rollover operation fails for any reason.

getActiveFileName

public java.lang.String getActiveFileName()
Return the value of the ActiveFile option.

See Also:

getMaxIndex

public int getMaxIndex()

getMinIndex

public int getMinIndex()

setMaxIndex

public void setMaxIndex(int maxIndex)

setMinIndex

public void setMinIndex(int minIndex)

Log4j 1.3alpha-6

Copyright 2000-2005 Apache Software Foundation.