java.lang.Objectorg.apache.log4j.AppenderSkeleton
org.apache.log4j.WriterAppender
org.apache.log4j.FileAppender
org.apache.log4j.CompositeRollingAppender
All Implemented Interfaces:
OptionHandler, Appender
CompositeRollingAppender combines RollingFileAppender and DailyRollingFileAppender
It can function as either or do both at the same time (making size
based rolling files like RollingFileAppender until a data/time boundary
is crossed at which time it rolls all of those files as per the DailyRollingFileAppender)
based on the setting for rollingStyle.
To use CompositeRollingAppender to roll log files as they reach a certain
size (like RollingFileAppender), set rollingStyle=1 (@see config.size)
To use CompositeRollingAppender to roll log files at certain time intervals
(daily for example), set rollingStyle=2 and a datePattern (@see config.time)
To have CompositeRollingAppender roll log files at a certain size AND rename those
according to time intervals, set rollingStyle=3 (@see config.composite)
A of few additional optional features have been added:
-- Attach date pattern for current log file (@see staticLogFileName)
-- Backup number increments for newer files (@see countDirection)
-- Infinite number of backups by file size (@see maxSizeRollBackups)
A few notes and warnings: For large or infinite number of backups
countDirection > 0 is highly recommended, with staticLogFileName = false if
time based rolling is also used -- this will reduce the number of file renamings
to few or none. Changing staticLogFileName or countDirection without clearing
the directory could have nasty side effects. If Date/Time based rolling
is enabled, CompositeRollingAppender will attempt to roll existing files
in the directory without a date/time tag based on the last modified date
of the base log files last modification.
A maximum number of backups based on date/time boundries would be nice
but is not yet implemented.
Kevin - SteppeHeinz - RichterEirik - LygreCeki - Gülcü| Field Summary | ||
|---|---|---|
| static final int | TOP_OF_TROUBLE | |
| static final int | TOP_OF_MINUTE | |
| static final int | TOP_OF_HOUR | |
| static final int | HALF_DAY | |
| static final int | TOP_OF_DAY | |
| static final int | TOP_OF_WEEK | |
| static final int | TOP_OF_MONTH | |
| static final int | BY_SIZE | Style of rolling to use |
| static final int | BY_DATE | |
| static final int | BY_COMPOSITE | |
| static final String | S_BY_SIZE | |
| static final String | S_BY_DATE | |
| static final String | S_BY_COMPOSITE | |
| Date | now | Holds date of last roll over |
| SimpleDateFormat | sdf | |
| RollingCalendar | rc | Helper class to determine next rollover time |
| int | checkPeriod | Current period for roll overs |
| protected long | maxFileSize | The default maximum file size is 10MB. |
| protected int | maxSizeRollBackups | There is zero backup files by default. |
| protected int | curSizeRollBackups | How many sized based backups have been made so far |
| protected int | maxTimeRollBackups | not yet implemented |
| protected int | curTimeRollBackups | |
| protected int | countDirection | By default newer files have lower numbers. (countDirection < 0) ie. log.1 is most recent, log.5 is the 5th backup, etc... countDirection > 0 does the opposite ie. log.1 is the first backup made, log.5 is the 5th backup made, etc. For infinite backups use countDirection > 0 to reduce rollOver costs. |
| protected int | rollingStyle | Style of rolling to Use. BY_SIZE (1), BY_DATE(2), BY COMPOSITE(3) |
| protected boolean | rollDate | |
| protected boolean | rollSize | |
| protected boolean | staticLogFileName | By default file.log is always the current file. Optionally file.log.yyyy-mm-dd for current formated datePattern can by the currently logging file (or file.log.curSizeRollBackup or even file.log.yyyy-mm-dd.curSizeRollBackup) This will make time based roll overs with a large number of backups much faster -- it won't have to rename all the backups! |
| protected String | baseFileName | FileName provided in configuration. Used for rolling properly |
| Fields inherited from org.apache.log4j.FileAppender: |
|---|
| fileAppend, fileName, bufferedIO, bufferSize |
| Fields inherited from org.apache.log4j.WriterAppender: |
|---|
| immediateFlush, encoding, qw |
| Fields inherited from org.apache.log4j.AppenderSkeleton: |
|---|
| layout, name, threshold, errorHandler, headFilter, tailFilter, closed |
| Constructor: |
|---|
|
filename. The opened filename will become the output
destination for this appender.
The file will be appended to. DatePattern is default. |
CompositeRollingAppender and open the
file designated by filename. The opened filename will
become the ouput destination for this appender. |
filename. The opened filename will become the ouput
destination for this appender.
If the |
filename. The opened filename will become the ouput
destination for this appender. |
| Method from org.apache.log4j.CompositeRollingAppender Summary: |
|---|
| activateOptions, computeCheckPeriod, deleteFile, existingInit, getCountDirection, getDatePattern, getMaxSizeRollBackups, getMaximumFileSize, getRollingStyle, getStaticLogFileName, rollFile, rollOverSize, rollOverTime, setCountDirection, setDatePattern, setFile, setFile, setMaxFileSize, setMaxFileSize, setMaxSizeRollBackups, setMaximumFileSize, setQWForFiles, setRollingStyle, setStaticLogFileName, setStaticLogFileName, subAppend |
| Methods from org.apache.log4j.FileAppender: |
|---|
| activateOptions, closeFile, getAppend, getBufferSize, getBufferedIO, getFile, reset, setAppend, setBufferSize, setBufferedIO, setFile, setFile, setQWForFiles |
| Methods from org.apache.log4j.WriterAppender: |
|---|
| activateOptions, append, checkEntryConditions, close, closeWriter, createWriter, getEncoding, getImmediateFlush, requiresLayout, reset, setEncoding, setErrorHandler, setImmediateFlush, setWriter, subAppend, writeFooter, writeHeader |
| Methods from org.apache.log4j.AppenderSkeleton: |
|---|
| activateOptions, addFilter, append, clearFilters, doAppend, finalize, getErrorHandler, getFilter, getFirstFilter, getLayout, getName, getThreshold, isAsSevereAsThreshold, setErrorHandler, setLayout, setName, setThreshold |
| Methods from java.lang.Object: |
|---|
| equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method from org.apache.log4j.CompositeRollingAppender Detail: |
|---|
existingInit to initialize
the current # of backups. |
|
|
activateOptions. The following is done:A) determine curSizeRollBackups B) determine curTimeRollBackups (not implemented) C) initiates a roll over if needed for crossing a date boundary since the last run. |
|
|
|
|
|
|
from to file to. It
also checks for existence of target file and deletes if it does. |
If the maximum number of size based backups is reached
( If If |
|
|
|
|
staticLogFileName
is false then the fully qualified name is determined and used. |
This method is equivalent to #setMaxFileSize except
that it is required for differentiating the setter taking a
|
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. |
Set the maximum number of backup files to keep around based on file size. The MaxSizeRollBackups option determines how many backup
files are kept before the oldest is erased. This option takes
an integer value. If set to zero, then there will be no
backup files and the log file will be truncated when it reaches
The maximum applys to -each- time based group of files and -not- the total. Using a daily roll the maximum total files would be (#days run) * (maxSizeRollBackups) |
This method is equivalent to #setMaxFileSize except
that it is required for differentiating the setter taking a
|
|
|
|
|
|