Package org.jboss.logmanager.handlers
Class PeriodicRotatingFileHandler
- java.lang.Object
-
- java.util.logging.Handler
-
- org.jboss.logmanager.ExtHandler
-
- org.jboss.logmanager.handlers.WriterHandler
-
- org.jboss.logmanager.handlers.OutputStreamHandler
-
- org.jboss.logmanager.handlers.FileHandler
-
- org.jboss.logmanager.handlers.PeriodicRotatingFileHandler
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable,FlushableCloseable,Protectable
- Direct Known Subclasses:
PeriodicSizeRotatingFileHandler
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 tosetSuffix(String).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPeriodicRotatingFileHandler.PeriodPossible period values.
-
Field Summary
Fields Modifier and Type Field Description private java.text.SimpleDateFormatformatprivate longnextRolloverprivate java.lang.StringnextSuffixprivate PeriodicRotatingFileHandler.Periodperiodprivate java.util.TimeZonetimeZone-
Fields inherited from class org.jboss.logmanager.handlers.WriterHandler
outputLock
-
Fields inherited from class org.jboss.logmanager.ExtHandler
handlers, handlersUpdater
-
-
Constructor Summary
Constructors Constructor Description PeriodicRotatingFileHandler()Construct a new instance with no formatter and no output file.PeriodicRotatingFileHandler(java.io.File file, java.lang.String suffix)Construct a new instance with the given output file.PeriodicRotatingFileHandler(java.io.File file, java.lang.String suffix, boolean append)Construct a new instance with the given output file and append setting.PeriodicRotatingFileHandler(java.lang.String fileName)Construct a new instance with the given output file.PeriodicRotatingFileHandler(java.lang.String fileName, boolean append)Construct a new instance with the given output file and append setting.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcalcNextRollover(long fromTime)protected java.lang.StringgetNextSuffix()Returns the suffix to be used.java.util.TimeZonegetTimeZone()Get the configured time zone for this handler.private static <T extends java.lang.Comparable<? super T>>
Tmin(T a, T b)protected voidpreWrite(ExtLogRecord record)Execute any pre-write policy, such as file rotation.private voidrollOver()voidsetFile(java.io.File file)Set the output file.voidsetSuffix(java.lang.String suffix)Set the suffix string.voidsetTimeZone(java.util.TimeZone timeZone)Set the configured time zone for this handler.-
Methods inherited from class org.jboss.logmanager.handlers.FileHandler
getFile, setAppend, 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, checkAccess, clearHandlers, disableAccess, enableAccess, getHandlers, isAutoFlush, isEnabled, protect, publish, publish, removeHandler, setAutoFlush, setEnabled, setErrorManager, setFilter, setFormatter, setHandlers, setLevel, unprotect
-
-
-
-
Field Detail
-
format
private java.text.SimpleDateFormat format
-
nextSuffix
private java.lang.String nextSuffix
-
period
private PeriodicRotatingFileHandler.Period period
-
nextRollover
private long nextRollover
-
timeZone
private java.util.TimeZone timeZone
-
-
Constructor Detail
-
PeriodicRotatingFileHandler
public PeriodicRotatingFileHandler()
Construct a new instance with no formatter and no output file.
-
PeriodicRotatingFileHandler
public PeriodicRotatingFileHandler(java.lang.String fileName) throws java.io.FileNotFoundExceptionConstruct a new instance with the given output file.- Parameters:
fileName- the file name- Throws:
java.io.FileNotFoundException- if the file could not be found on open
-
PeriodicRotatingFileHandler
public PeriodicRotatingFileHandler(java.lang.String fileName, boolean append) throws java.io.FileNotFoundExceptionConstruct a new instance with the given output file and append setting.- Parameters:
fileName- the file nameappend-trueto append,falseto overwrite- Throws:
java.io.FileNotFoundException- if the file could not be found on open
-
PeriodicRotatingFileHandler
public PeriodicRotatingFileHandler(java.io.File file, java.lang.String suffix) throws java.io.FileNotFoundExceptionConstruct a new instance with the given output file.- Parameters:
file- the filesuffix- the format suffix to use- Throws:
java.io.FileNotFoundException- if the file could not be found on open
-
PeriodicRotatingFileHandler
public PeriodicRotatingFileHandler(java.io.File file, java.lang.String suffix, boolean append) throws java.io.FileNotFoundExceptionConstruct a new instance with the given output file and append setting.- Parameters:
file- the filesuffix- the format suffix to useappend-trueto append,falseto overwrite- Throws:
java.io.FileNotFoundException- if the file could not be found on open
-
-
Method Detail
-
setFile
public void setFile(java.io.File file) throws java.io.FileNotFoundExceptionDescription copied from class:FileHandlerSet the output file.- Overrides:
setFilein classFileHandler- Parameters:
file- the file- Throws:
java.io.FileNotFoundException- if an error occurs opening the file
-
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:
preWritein classWriterHandler- Parameters:
record- the record about to be logged
-
setSuffix
public void setSuffix(java.lang.String suffix) throws java.lang.IllegalArgumentExceptionSet the suffix string. The string is in a format which can be understood bySimpleDateFormat. The period of the rotation is automatically calculated based on the suffix.- Parameters:
suffix- the suffix- Throws:
java.lang.IllegalArgumentException- if the suffix is not valid
-
getNextSuffix
protected final java.lang.String getNextSuffix()
Returns the suffix to be used.- Returns:
- the suffix to be used
-
rollOver
private void rollOver()
-
calcNextRollover
private void calcNextRollover(long fromTime)
-
getTimeZone
public java.util.TimeZone getTimeZone()
Get the configured time zone for this handler.- Returns:
- the configured time zone
-
setTimeZone
public void setTimeZone(java.util.TimeZone timeZone)
Set the configured time zone for this handler.- Parameters:
timeZone- the configured time zone
-
min
private static <T extends java.lang.Comparable<? super T>> T min(T a, T b)
-
-