org.dspace.app.util
Class DailyFileAppender

java.lang.Object
  extended by org.apache.log4j.AppenderSkeleton
      extended by org.apache.log4j.WriterAppender
          extended by org.apache.log4j.FileAppender
              extended by org.dspace.app.util.DailyFileAppender
All Implemented Interfaces:
Appender, OptionHandler

public class DailyFileAppender
extends FileAppender

Special log appender for log4j. Adds the current date (ie. year-mon) to the end of the file name, so that rolling on to the next log is simply a case of starting a new one - no renaming of old logs. This is advisable if you are using Windows, and have multiple applications (ie. dspace, dspace-oai, dspace-sword) that all want to write to the same log file, as each would otherwise try to rename the old files during rollover. An example log4j.properties (one log per month, retains three months of logs) log4j.rootCategory=INFO, A1 log4j.appender.A1=org.dspace.app.util.DailyFileAppender log4j.appender.A1.File=@@log.dir@@/dspace.log log4j.appender.A1.DatePattern=yyyy-MM log4j.appender.A1.MaxLogs=3 log4j.appender.A1.layout=org.apache.log4j.PatternLayout log4j.appender.A1.layout.ConversionPattern=%d %-5p %c @ %m%n


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
DailyFileAppender()
          Default constructor.
 
Method Summary
 void activateOptions()
           
 String getDatePattern()
           
 String getFile()
           
 int getMaxLogs()
           
 boolean getWithHost()
           
 void setDatePattern(String pstrPattern)
           
 void setFile(String file)
           
 void setMaxLogs(int ml)
           
 void setWithHost(boolean wh)
           
protected  void subAppend(LoggingEvent pobjEvent)
           
 
Methods inherited from class org.apache.log4j.FileAppender
closeFile, getAppend, getBufferedIO, getBufferSize, reset, setAppend, setBufferedIO, setBufferSize, setFile, setQWForFiles
 
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
 

Constructor Detail

DailyFileAppender

public DailyFileAppender()
Default constructor. This is required as the appender class is dynamically loaded.

Method Detail

activateOptions

public void activateOptions()
Specified by:
activateOptions in interface OptionHandler
Overrides:
activateOptions in class FileAppender

getDatePattern

public String getDatePattern()

getFile

public String getFile()
Overrides:
getFile in class FileAppender

getWithHost

public boolean getWithHost()

getMaxLogs

public int getMaxLogs()

setDatePattern

public void setDatePattern(String pstrPattern)

setFile

public void setFile(String file)
Overrides:
setFile in class FileAppender

setWithHost

public void setWithHost(boolean wh)

setMaxLogs

public void setMaxLogs(int ml)

subAppend

protected void subAppend(LoggingEvent pobjEvent)
Overrides:
subAppend in class WriterAppender


Copyright © 2010 DuraSpace. All Rights Reserved.