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:
Flushable,AutoCloseable
- Direct Known Subclasses:
PeriodicSizeRotatingFileHandler
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
Nested ClassesModifier and TypeClassDescriptionstatic enumPossible period values. -
Field Summary
Fields inherited from class org.jboss.logmanager.ExtHandler
handlers, handlersUpdater, lock -
Constructor Summary
ConstructorsConstructorDescriptionConstruct 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
Modifier and TypeMethodDescriptionprotected final StringReturns the suffix to be used.Get the configured time zone for this handler.protected voidpreWrite(ExtLogRecord record) Execute any pre-write policy, such as file rotation.voidSet the output file.voidSet the suffix string.voidsetTimeZone(TimeZone timeZone) Set the configured time zone for this handler.Methods inherited from class org.jboss.logmanager.handlers.FileHandler
getFile, setAppend, setFileNameMethods inherited from class org.jboss.logmanager.handlers.OutputStreamHandler
getCharset, setCharsetPrivate, setOutputStream, setWriterMethods inherited from class org.jboss.logmanager.handlers.WriterHandler
close, doPublish, flush, isCheckHeadEncoding, isCheckTailEncoding, safeClose, setCheckHeadEncoding, setCheckTailEncodingMethods inherited from class org.jboss.logmanager.ExtHandler
addHandler, checkAccess, checkAccess, clearHandlers, getEncoding, getErrorManager, getFilter, getFormatter, getHandlers, getLevel, isAutoFlush, isCallerCalculationRequired, isCloseChildren, isEnabled, publish, publish, publishToNestedHandlers, removeHandler, reportError, reportError, setAutoFlush, setCharset, setCloseChildren, setEnabled, setEncoding, setErrorManager, setFilter, setFormatter, setHandlers, setLevelMethods inherited from class java.util.logging.Handler
isLoggable
-
Constructor Details
-
PeriodicRotatingFileHandler
public PeriodicRotatingFileHandler()Construct a new instance with no formatter and no output file. -
PeriodicRotatingFileHandler
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
Construct a new instance with the given output file and append setting.- Parameters:
fileName- the file nameappend-trueto append,falseto overwrite- Throws:
FileNotFoundException- if the file could not be found on open
-
PeriodicRotatingFileHandler
Construct a new instance with the given output file.- Parameters:
file- the filesuffix- 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 filesuffix- the format suffix to useappend-trueto append,falseto overwrite- Throws:
FileNotFoundException- if the file could not be found on open
-
-
Method Details
-
setFile
Description copied from class:FileHandlerSet the output file.- Overrides:
setFilein classFileHandler- Parameters:
file- the file- Throws:
FileNotFoundException- if an error occurs opening the file
-
preWrite
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
Set the suffix string. The string is in a format which can be understood byDateTimeFormatter. The period of the rotation is automatically calculated based on the suffix.If the suffix ends with
.gzor.zipthe file will be compressed on rotation.- Parameters:
suffix- the suffix- Throws:
IllegalArgumentException- if the suffix is not valid
-
getNextSuffix
Returns the suffix to be used.- Returns:
- the suffix to be used
-
getTimeZone
Get the configured time zone for this handler.- Returns:
- the configured time zone
-
setTimeZone
Set the configured time zone for this handler.- Parameters:
timeZone- the configured time zone
-