JBoss LogManager 1.1.0.CR6

org.jboss.logmanager.handlers
Class PeriodicRotatingFileHandler

java.lang.Object
  extended by java.util.logging.Handler
      extended by org.jboss.logmanager.ExtHandler
          extended by org.jboss.logmanager.handlers.WriterHandler
              extended by org.jboss.logmanager.handlers.OutputStreamHandler
                  extended by org.jboss.logmanager.handlers.FileHandler
                      extended by org.jboss.logmanager.handlers.PeriodicRotatingFileHandler
All Implemented Interfaces:
Flushable

public class PeriodicRotatingFileHandler
extends FileHandler

A file handler which rotates the log at a preset time interval. The interval is determined by the content of the suffix string which is passed in to setSuffix(String).


Nested Class Summary
static class PeriodicRotatingFileHandler.Period
          Possible period values.
 
Field Summary
 
Fields inherited from class org.jboss.logmanager.handlers.WriterHandler
outputLock
 
Fields inherited from class org.jboss.logmanager.ExtHandler
handlers, handlersUpdater
 
Constructor Summary
PeriodicRotatingFileHandler()
          Construct a new instance with no formatter and no output file.
PeriodicRotatingFileHandler(File file, String suffix)
          Construct a new instance with the given output file.
PeriodicRotatingFileHandler(File file, String suffix, boolean append)
          Construct a new instance with the given output file and append setting.
PeriodicRotatingFileHandler(String fileName)
          Construct a new instance with the given output file.
PeriodicRotatingFileHandler(String fileName, boolean append)
          Construct a new instance with the given output file and append setting.
 
Method Summary
protected  void preWrite(ExtLogRecord record)
          Execute any pre-write policy, such as file rotation.
 void setSuffix(String suffix)
          Set the suffix string.
 
Methods inherited from class org.jboss.logmanager.handlers.FileHandler
getFile, setAppend, setFile, setFileName
 
Methods inherited from class org.jboss.logmanager.handlers.OutputStreamHandler
getEncoding, setEncoding, setOutputStream, setWriter
 
Methods inherited from class org.jboss.logmanager.handlers.WriterHandler
close, doPublish, flush, safeClose
 
Methods inherited from class org.jboss.logmanager.ExtHandler
addHandler, checkAccess, clearHandlers, getHandlers, isAutoFlush, publish, publish, removeHandler, setAutoFlush, setHandlers
 
Methods inherited from class java.util.logging.Handler
getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError, setErrorManager, setFilter, setFormatter, setLevel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PeriodicRotatingFileHandler

public PeriodicRotatingFileHandler()
Construct a new instance with no formatter and no output file.


PeriodicRotatingFileHandler

public PeriodicRotatingFileHandler(String fileName)
                            throws FileNotFoundException
Construct a new instance with the given output file.

Parameters:
fileName - the file name
Throws:
FileNotFoundException - if the file could not be found on open

PeriodicRotatingFileHandler

public PeriodicRotatingFileHandler(String fileName,
                                   boolean append)
                            throws FileNotFoundException
Construct a new instance with the given output file and append setting.

Parameters:
fileName - the file name
append - true to append, false to overwrite
Throws:
FileNotFoundException - if the file could not be found on open

PeriodicRotatingFileHandler

public PeriodicRotatingFileHandler(File file,
                                   String suffix)
                            throws FileNotFoundException
Construct a new instance with the given output file.

Parameters:
file - the file
suffix - the format suffix to use
Throws:
FileNotFoundException - if the file could not be found on open

PeriodicRotatingFileHandler

public PeriodicRotatingFileHandler(File file,
                                   String suffix,
                                   boolean append)
                            throws FileNotFoundException
Construct a new instance with the given output file and append setting.

Parameters:
file - the file
suffix - the format suffix to use
append - true to append, false to overwrite
Throws:
FileNotFoundException - if the file could not be found on open
Method Detail

preWrite

protected void preWrite(ExtLogRecord record)
Execute any pre-write policy, such as file rotation. The write lock is held during this method, so make it quick. The default implementation does nothing. This implementation checks to see if the scheduled rollover time has yet occurred.

Overrides:
preWrite in class WriterHandler
Parameters:
record - the record about to be logged

setSuffix

public void setSuffix(String suffix)
               throws IllegalArgumentException
Set the suffix string. The string is in a format which can be understood by SimpleDateFormat. The period of the rotation is automatically calculated based on the suffix.

Parameters:
suffix - the suffix
Throws:
IllegalArgumentException - if the suffix is not valid

JBoss LogManager 1.1.0.CR6

Copyright © 2009 JBoss, a division of Red Hat, Inc.