net.lucidviews.util.log4j
Class FreshRollingFileAppender

java.lang.Object
  extended by org.apache.log4j.AppenderSkeleton
      extended by org.apache.log4j.WriterAppender
          extended by org.apache.log4j.FileAppender
              extended by org.apache.log4j.RollingFileAppender
                  extended by net.lucidviews.util.log4j.FreshRollingFileAppender
All Implemented Interfaces:
org.apache.log4j.Appender, org.apache.log4j.spi.OptionHandler

public class FreshRollingFileAppender
extends org.apache.log4j.RollingFileAppender

FreshRollingFileAppender extends RollingFileAppender inheriting and retaining all the standard file backup functionality while ensuring a fresh log file is created each time the application is started.

Since:
1.0
Version:
$Revision: 1.2 $
Author:
Stephen Battey
See Also:
RollingFileAppender

Field Summary
private  boolean firstLoggingEvent
          Flag set just until the first logging event occurs.
protected  boolean freshLogAtStartup
          Flag indicating if a new log file should be created for this instance of the application.
 
Fields inherited from class org.apache.log4j.RollingFileAppender
maxBackupIndex, maxFileSize
 
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
FreshRollingFileAppender()
          The default constructor.
 
Method Summary
 boolean isFreshLogAtStartup()
          Check if this appender has created a fresh log file when the application started.
 void setFreshLogAtStartup(boolean freshLogAtStartup)
          Tell this appender whether to create a fresh log file when the application starts.
protected  void subAppend(org.apache.log4j.spi.LoggingEvent event)
           
 
Methods inherited from class org.apache.log4j.RollingFileAppender
getMaxBackupIndex, getMaximumFileSize, rollOver, setFile, setMaxBackupIndex, setMaxFileSize, setMaximumFileSize, setQWForFiles
 
Methods inherited from class org.apache.log4j.FileAppender
activateOptions, closeFile, getAppend, getBufferedIO, getBufferSize, getFile, reset, setAppend, setBufferedIO, setBufferSize, setFile
 
Methods inherited from class org.apache.log4j.WriterAppender
append, checkEntryConditions, close, closeWriter, createWriter, getEncoding, getImmediateFlush, requiresLayout, setEncoding, 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

freshLogAtStartup

protected boolean freshLogAtStartup
Flag indicating if a new log file should be created for this instance of the application.


firstLoggingEvent

private boolean firstLoggingEvent
Flag set just until the first logging event occurs.

Constructor Detail

FreshRollingFileAppender

public FreshRollingFileAppender()
The default constructor.

Method Detail

subAppend

protected void subAppend(org.apache.log4j.spi.LoggingEvent event)
Overrides:
subAppend in class org.apache.log4j.RollingFileAppender

isFreshLogAtStartup

public boolean isFreshLogAtStartup()
Check if this appender has created a fresh log file when the application started.

Returns:
true if a new log file was created at startup

setFreshLogAtStartup

public void setFreshLogAtStartup(boolean freshLogAtStartup)
Tell this appender whether to create a fresh log file when the application starts.

Parameters:
freshLogAtStartup - true if a new log file should be created at startup