Class DatedRollingFileAppender

  extended by org.apache.log4j.AppenderSkeleton
      extended by org.apache.log4j.WriterAppender
          extended by org.apache.log4j.FileAppender
              extended by net.rim.pushsdk.commons.DatedRollingFileAppender
All Implemented Interfaces:
org.apache.log4j.Appender, org.apache.log4j.spi.OptionHandler

public class DatedRollingFileAppender
extends org.apache.log4j.FileAppender

The standard Log4J DailyRollingFileAppender writes to a log file (say foo.log) until some pre-established criteria has been met (i.e. the current day has changed). At that point, the existing log file is closed and renamed using some sort of file name extension (i.e. moved to foo.log.2009-11-20). The original log file is then re-created and the system continues to chug along. The DatedRollingFileAppender, described here, is a drop in replacement for the Log4J DailyRollingFileAppender but which names the current day's log file with the current date appended to the end i.e. foo.log.2009-11-20 right away, when the date rolls over it creates a brand new log file instead of moving/renaming the old one i.e. foo.log.2009-11-21.

Based on code by:

Geoff Mottram on August 28, 2004 whose software was written and placed in the public domain.

Onofre De Melo, Marco Di Cesare

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
Method Summary
 void activateOptions()
 void append(org.apache.log4j.spi.LoggingEvent event)
          Before actually logging, this method will check whether it is time to do a roll-over.
 String getDatePattern()
          Returns the value of the DatePattern option.
 void setDatePattern(String pattern)
          The DatePattern takes a string in the same format as expected by SimpleDateFormat.
 void setFile(String file)
Methods inherited from class org.apache.log4j.FileAppender
closeFile, getAppend, getBufferedIO, getBufferSize, getFile, reset, setAppend, setBufferedIO, setBufferSize, setFile, setQWForFiles
Methods inherited from class org.apache.log4j.WriterAppender
checkEntryConditions, close, closeWriter, createWriter, getEncoding, getImmediateFlush, requiresLayout, setEncoding, setErrorHandler, setImmediateFlush, setWriter, subAppend, 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

Constructor Detail


public DatedRollingFileAppender()
Method Detail


public void setFile(String file)
setFile in class org.apache.log4j.FileAppender


public void activateOptions()
Specified by:
activateOptions in interface org.apache.log4j.spi.OptionHandler
activateOptions in class org.apache.log4j.FileAppender


public void append(org.apache.log4j.spi.LoggingEvent event)
Before actually logging, this method will check whether it is time to do a roll-over. If it is, it will schedule the next roll-over time and then roll-over.

append in class org.apache.log4j.WriterAppender


public String getDatePattern()
Returns the value of the DatePattern option.


public void setDatePattern(String pattern)
The DatePattern takes a string in the same format as expected by SimpleDateFormat. This options determines the roll-over schedule.

Copyright © 2011 Research In Motion. All Rights Reserved.