|
Log4j 1.3alpha-1 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.log4j.AppenderSkeleton | +--org.apache.log4j.WriterAppender | +--org.apache.log4j.FileAppender | +--org.apache.log4j.rolling.RollingFileAppender
RollingFileAppender
extends FileAppender
to backup the log files
depending on RollingPolicy
and TriggeringPolicy
.
To be of any use, a RollingFileAppender
instance must have both
a RollingPolicy
and a TriggeringPolicy
set up.
However, if its RollingPolicy
also implements the
TriggeringPolicy
interface, then only the former needs to be
set up. For example, TimeBasedRollingPolicy
acts both as a
RollingPolicy
and a TriggeringPolicy
.
RollingFileAppender
can be configured programattically or
using JoranConfigurator
. Here is a sample
configration file:
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE log4j:configuration> <log4j:configuration debug="true"> <appender name="ROLL" class="org.apache.log4j.rolling.RollingFileAppender"> <rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy"> <param name="FileNamePattern" value="/wombat/foo.%d{yyyy-MM}.gz"/> </rollingPolicy> <layout class="org.apache.log4j.PatternLayout"> <param name="ConversionPattern" value="%c{1} - %m%n"/> </layout> </appender> <root"> <appender-ref ref="ROLL"/> </root> </log4j:configuration>
This configuration file specifies a monthly rollover schedule including
automatic compression of the archived files. See
TimeBasedRollingPolicy
for more details.
Field Summary |
Fields inherited from class org.apache.log4j.FileAppender |
bufferedIO, bufferSize, fileAppend, fileName |
Fields inherited from class org.apache.log4j.WriterAppender |
encoding, immediateFlush, qw |
Fields inherited from class org.apache.log4j.AppenderSkeleton |
closed, errorHandler, headFilter, layout, name, tailFilter, threshold |
Constructor Summary | |
RollingFileAppender()
The default constructor simply calls its parents constructor . |
Method Summary | |
void |
activateOptions()
If the value of File is not null , then FileAppender.setFile(java.lang.String) is called with the values of File and
Append properties. |
RollingPolicy |
getRollingPolicy()
|
TriggeringPolicy |
getTriggeringPolicy()
|
void |
rollover()
Implements the usual roll over behaviour. |
void |
setRollingPolicy(RollingPolicy policy)
Sets the rolling policy. |
void |
setTriggeringPolicy(TriggeringPolicy policy)
|
protected void |
subAppend(LoggingEvent event)
This method differentiates RollingFileAppender from its super class. |
Methods inherited from class org.apache.log4j.FileAppender |
closeFile, getAppend, getBufferedIO, getBufferSize, getFile, setAppend, setBufferedIO, setBufferSize, setFile, setFile, setQWForFiles |
Methods inherited from class org.apache.log4j.WriterAppender |
append, checkEntryConditions, close, closeWriter, createWriter, getEncoding, getImmediateFlush, requiresLayout, setEncoding, setErrorHandler, setImmediateFlush, setWriter, writeFooter, writeHeader, xreset |
Methods inherited from class org.apache.log4j.AppenderSkeleton |
addFilter, clearFilters, doAppend, finalize, getErrorHandler, getFilter, getFirstFilter, getLayout, getLogger, getName, getThreshold, isAsSevereAsThreshold, setLayout, setName, setThreshold |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public RollingFileAppender()
parents constructor
.
Method Detail |
public void activateOptions()
FileAppender
null
, then FileAppender.setFile(java.lang.String)
is called with the values of File and
Append properties.
activateOptions
in interface OptionHandler
activateOptions
in class FileAppender
public void rollover()
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.
protected void subAppend(LoggingEvent event)
subAppend
in class WriterAppender
public RollingPolicy getRollingPolicy()
public TriggeringPolicy getTriggeringPolicy()
public void setRollingPolicy(RollingPolicy policy)
TriggeringPolicy
, then the triggering policy for this appender
is automatically set to be the policy argument.
policy
- public void setTriggeringPolicy(TriggeringPolicy policy)
|
Log4j 1.3alpha-1 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |