Save This Page
Home » slf4j-1.5.5 » org.apache » log4j » [javadoc | source]
org.apache.log4j
public class: RollingFileAppender [javadoc | source]
java.lang.Object
   org.apache.log4j.AppenderSkeleton
      org.apache.log4j.WriterAppender
         org.apache.log4j.FileAppender
            org.apache.log4j.RollingFileAppender

All Implemented Interfaces:
    OptionHandler, Appender

Direct Known Subclasses:
    ExternallyRolledFileAppender

RollingFileAppender extends FileAppender to backup the log files when they reach a certain size.
Field Summary
protected  long maxFileSize    The default maximum file size is 10MB. 
protected  int maxBackupIndex    There is one backup file by default. 
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:
 public RollingFileAppender() 
 public RollingFileAppender(Layout layout,
    String filename) throws IOException 
    Instantiate a FileAppender and open the file designated by filename. The opened filename will become the output destination for this appender.

    The file will be appended to.

 public RollingFileAppender(Layout layout,
    String filename,
    boolean append) throws IOException 
    Instantiate a RollingFileAppender and open the file designated by 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.

Method from org.apache.log4j.RollingFileAppender Summary:
getMaxBackupIndex,   getMaximumFileSize,   rollOver,   setFile,   setMaxBackupIndex,   setMaxFileSize,   setMaximumFileSize,   setQWForFiles,   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.RollingFileAppender Detail:
 public int getMaxBackupIndex() 
    Returns the value of the MaxBackupIndex option.
 public long getMaximumFileSize() 
    Get the maximum size that the output file is allowed to reach before being rolled over to backup files.
 public  void rollOver() 
    Implements the usual roll over behaviour.

    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 synchronized  void setFile(String fileName,
    boolean append,
    boolean bufferedIO,
    int bufferSize) throws IOException 
 public  void setMaxBackupIndex(int maxBackups) 
    Set the maximum number of backup files to keep around.

    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(String value) 
    Set the maximum size that the output file is allowed to reach before being rolled over to backup files.

    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.

 public  void setMaximumFileSize(long maxFileSize) 
    Set the maximum size that the output file is allowed to reach before being rolled over to backup files.

    This method is equivalent to #setMaxFileSize except that it is required for differentiating the setter taking a long argument from the setter taking a String argument by the JavaBeans Introspector .

 protected  void setQWForFiles(Writer writer) 
 protected  void subAppend(LoggingEvent event) 
    This method differentiates RollingFileAppender from its super class.