Log4j 0.9.1

org.log4j.varia
Class ResilientFileAppender

java.lang.Object
  |
  +--org.log4j.AppenderSkeleton
        |
        +--org.log4j.FileAppender
              |
              +--org.log4j.varia.ResilientFileAppender
All Implemented Interfaces:
Appender, OptionHandler

public class ResilientFileAppender
extends FileAppender

This appender is resilient against moving of the log output file. Before every write operation, it checks whether the target log file has been moved by an external process. If that is the case, a new output file is created.

This method of detecting externally triggered roll overs has the following disadvantages:

For all these reasons, it is recommended that you use the ExternallyRolledFileAppender.

Since:
version 0.9.0
Author:
Ceki Gülcü

Fields inherited from class org.log4j.FileAppender
APPEND_OPTION, FILE_OPTION, fileAppend, fileName, IMMEDIATE_FLUSH_OPTION, immediateFlush, qw, qwIsOurs, tp
 
Fields inherited from class org.log4j.AppenderSkeleton
closed, errorHandler, headFilter, layout, name, tailFilter, threshold, THRESHOLD_OPTION
 
Constructor Summary
ResilientFileAppender()
          Thia default constructor does nothing but call its super-class constructor.
ResilientFileAppender(Layout layout, Writer writer)
          This constructor does nothing but call its super-class constructor with the same parameters.
 
Method Summary
protected  boolean checkEntryConditions()
          This method determines if there is a sense in attempting to append.
protected  void reset()
           
 void setFile(String fileName, boolean append)
          Sets and opens the file where the log output will go.
 
Methods inherited from class org.log4j.FileAppender
activateOptions, append, close, closeWriterIfOurs, getOptionStrings, requiresLayout, setErrorHandler, setFile, setOption, setQWForFiles, setWriter, subAppend
 
Methods inherited from class org.log4j.AppenderSkeleton
addFilter, clearFilters, doAppend, finalize, getErrorHandler, getFirstFilter, getName, isAsSevereAsThreshold, setLayout, setName, setThreshold
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResilientFileAppender

public ResilientFileAppender()
Thia default constructor does nothing but call its super-class constructor.

ResilientFileAppender

public ResilientFileAppender(Layout layout,
                             Writer writer)
This constructor does nothing but call its super-class constructor with the same parameters.
Method Detail

checkEntryConditions

protected boolean checkEntryConditions()
Description copied from class: FileAppender
This method determines if there is a sense in attempting to append.

It checks whether there is a set output target and also if there is a set layout. If these checks fail, then the boolean value false is returned.

Overrides:
checkEntryConditions in class FileAppender

setFile

public void setFile(String fileName,
                    boolean append)
             throws IOException
Description copied from class: FileAppender

Sets and opens the file where the log output will go. The specified file must be writable.

If there was already an opened stream opened through this method, then the previous stream is closed first. If the stream was opened by the user and passed to setWriter, then the previous stream remains untouched. It is the users responsability to close it.

Overrides:
setFile in class FileAppender
Following copied from class: org.log4j.FileAppender
Parameters:
fileName - The path to the log file.
boolean - If true will append to fileName. Otherwise will truncate fileName.

reset

protected void reset()
Overrides:
reset in class FileAppender

Log4j 0.9.1

Please notify me about new log4j releases.