|
Log4j 1.1.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | 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.RollingFileAppender
RollingFileAppender extends FileAppender to backup the log files when they reach a certain size.
Field Summary | |
static String |
MAX_BACKUP_INDEX_OPTION
Deprecated. Options are now handled using the JavaBeans paradigm. This constant is not longer needed and will be removed in the near term. |
static String |
MAX_FILE_SIZE_OPTION
Deprecated. Options are now handled using the JavaBeans paradigm. This constant is not longer needed and will be removed in the near term. |
protected int |
maxBackupIndex
There is one backup file by default. |
protected long |
maxFileSize
The default maximum file size is 10MB. |
Fields inherited from class org.apache.log4j.FileAppender |
APPEND_OPTION, FILE_OPTION, fileAppend, fileName, qwIsOurs |
Fields inherited from class org.apache.log4j.WriterAppender |
IMMEDIATE_FLUSH_OPTION, immediateFlush, qw |
Fields inherited from class org.apache.log4j.AppenderSkeleton |
closed, errorHandler, headFilter, layout, name, tailFilter, threshold, THRESHOLD_OPTION |
Constructor Summary | |
RollingFileAppender()
The default constructor simply calls its parents constructor . |
|
RollingFileAppender(Layout layout,
String filename)
Instantiate a FileAppender and open the file designated by filename . |
|
RollingFileAppender(Layout layout,
String filename,
boolean append)
Instantiate a RollingFileAppender and open the file designated by filename . |
Method Summary | |
int |
getMaxBackupIndex()
Returns the value of the MaxBackupIndex option. |
long |
getMaximumFileSize()
Get the maximum size that the output file is allowed to reach before being rolled over to backup files. |
String[] |
getOptionStrings()
Deprecated. We now use JavaBeans introspection to configure components. Options strings are no longer needed. |
void |
rollOver()
Implements the usual roll over behaviour. |
void |
setFile(String fileName,
boolean append)
Sets and opens the file where the log output will go. |
void |
setMaxBackupIndex(int maxBackups)
Set the maximum number of backup files to keep around. |
void |
setMaxFileSize(long maxFileSize)
Deprecated. Use setMaximumFileSize(long) instead. |
void |
setMaxFileSize(String value)
Set the maximum size that the output file is allowed to reach before being rolled over to backup files. |
void |
setMaximumFileSize(long maxFileSize)
Set the maximum size that the output file is allowed to reach before being rolled over to backup files. |
void |
setOption(String key,
String value)
Set option to value .
|
protected void |
setQWForFiles(Writer writer)
Sets the quiet writer being used. |
protected void |
subAppend(LoggingEvent event)
This method differentiates RollingFileAppender from its super class. |
Methods inherited from class org.apache.log4j.FileAppender |
activateOptions, closeFile, getAppend, getFile, reset, setAppend, setFile |
Methods inherited from class org.apache.log4j.WriterAppender |
append, checkEntryConditions, close, closeWriter, getImmediateFlush, requiresLayout, setErrorHandler, setImmediateFlush, setWriter, writeFooter, writeHeader |
Methods inherited from class org.apache.log4j.AppenderSkeleton |
addFilter, clearFilters, doAppend, finalize, getErrorHandler, getFilter, getFirstFilter, getLayout, getName, getThreshold, isAsSevereAsThreshold, setLayout, setName, setThreshold |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String MAX_FILE_SIZE_OPTION
public static final String MAX_BACKUP_INDEX_OPTION
protected long maxFileSize
protected int maxBackupIndex
Constructor Detail |
public RollingFileAppender()
parents constructor
.public RollingFileAppender(Layout layout, String filename, boolean append) throws IOException
filename
. The opened filename will become the ouput
destination for this appender.
If the append
parameter is true, the file will be
appended to. Otherwise, the file desginated by
filename
will be truncated before being opened.
public RollingFileAppender(Layout layout, String filename) throws IOException
filename
. The opened filename will become the output
destination for this appender.
The file will be appended to.
Method Detail |
public int getMaxBackupIndex()
public long getMaximumFileSize()
public String[] getOptionStrings()
MAX_FILE_SIZE_OPTION
and MAX_BACKUP_INDEX_OPTION
in
addition to the options of FileAppender.getOptionStrings()
getOptionStrings
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.
public void setFile(String fileName, boolean append) throws IOException
FileAppender
Sets and opens the file where the log output will go. The specified file must be writable.
If there was already an opened file, then the previous file is closed first.
setFile
in class FileAppender
org.apache.log4j.FileAppender
fileName
- The path to the log file.append
- If true will append to fileName. Otherwise will
truncate fileName.public void setOption(String key, String value)
setOption
method.
OptionHandler
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 OptionHandler.activateOptions()
is
called.
setOption
in class FileAppender
public void setMaxBackupIndex(int maxBackups)
The MaxBackupIndex option determines how many backup
files are kept before the oldest is erased. This option takes
a positive integer value. If set to zero, then there will be no
backup files and the log file will be truncated when it reaches
MaxFileSize
.
public void setMaxFileSize(long maxFileSize)
setMaximumFileSize(long)
instead.
public void setMaximumFileSize(long maxFileSize)
This method is equivalent to setMaxFileSize(long)
except
that it is required for differentiating the setter taking a
long
argument from the setter taking a
String
argument by the JavaBeans Introspector
.
setMaxFileSize(String)
public void setMaxFileSize(String value)
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.
protected void setQWForFiles(Writer writer)
FileAppender
RollingFileAppender
.setQWForFiles
in class FileAppender
protected void subAppend(LoggingEvent event)
subAppend
in class WriterAppender
|
Log4j 1.1.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |