Class AsyncFileHandler
java.lang.Object
java.util.logging.Handler
org.apache.juli.FileHandler
org.apache.juli.AsyncFileHandler
A
FileHandler implementation that uses a queue of log entries.
Configuration properties are inherited from the FileHandler class. This class does not add its own
configuration properties for the logging configuration, but relies on the following system properties instead:
org.apache.juli.AsyncOverflowDropTypeDefault value:1org.apache.juli.AsyncMaxRecordCountDefault value:10000
See the System Properties page in the configuration reference of Tomcat.
-
Nested Class Summary
Nested classes/interfaces inherited from class FileHandler
FileHandler.ThreadFactory -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanIndicates whether this handler has been closed.static final intDefault maximum number of records in the queue.static final intDefault overflow drop type value.static final intConfigured maximum record count from system property.static final intOverflow policy: drop the current record.static final intOverflow policy: drop the first (oldest) record in the queue.static final intOverflow policy: flush the queue and retry.static final intOverflow policy: drop the last record in the queue.static final intConfigured overflow drop type from system property.Fields inherited from class FileHandler
DEFAULT_BUFFER_SIZE, DEFAULT_MAX_DAYS, writerLock -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an AsyncFileHandler with default settings.AsyncFileHandler(String directory, String prefix, String suffix) Constructs an AsyncFileHandler with the specified directory, prefix, and suffix.AsyncFileHandler(String directory, String prefix, String suffix, Integer maxDays) Constructs an AsyncFileHandler with the specified directory, prefix, suffix, and max days. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the currently open log file (if any).voidopen()Open the new log file for the date specified bydate.voidFormat and publish aLogRecord.protected voidpublishInternal(LogRecord record) Publishes a log record to the underlying handler.Methods inherited from class FileHandler
closeWriter, flush, openWriterMethods inherited from class Handler
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError, setEncoding, setErrorManager, setFilter, setFormatter, setLevel
-
Field Details
-
OVERFLOW_DROP_LAST
public static final int OVERFLOW_DROP_LASTOverflow policy: drop the last record in the queue.- See Also:
-
OVERFLOW_DROP_FIRST
public static final int OVERFLOW_DROP_FIRSTOverflow policy: drop the first (oldest) record in the queue.- See Also:
-
OVERFLOW_DROP_FLUSH
public static final int OVERFLOW_DROP_FLUSHOverflow policy: flush the queue and retry.- See Also:
-
OVERFLOW_DROP_CURRENT
public static final int OVERFLOW_DROP_CURRENTOverflow policy: drop the current record.- See Also:
-
DEFAULT_OVERFLOW_DROP_TYPE
public static final int DEFAULT_OVERFLOW_DROP_TYPEDefault overflow drop type value.- See Also:
-
DEFAULT_MAX_RECORDS
public static final int DEFAULT_MAX_RECORDSDefault maximum number of records in the queue.- See Also:
-
OVERFLOW_DROP_TYPE
public static final int OVERFLOW_DROP_TYPEConfigured overflow drop type from system property. -
MAX_RECORDS
public static final int MAX_RECORDSConfigured maximum record count from system property. -
closed
protected volatile boolean closedIndicates whether this handler has been closed.
-
-
Constructor Details
-
AsyncFileHandler
public AsyncFileHandler()Constructs an AsyncFileHandler with default settings. -
AsyncFileHandler
-
AsyncFileHandler
Constructs an AsyncFileHandler with the specified directory, prefix, suffix, and max days.- Parameters:
directory- The directory for log filesprefix- The log file name prefixsuffix- The log file name suffixmaxDays- Maximum number of days to keep log files
-
-
Method Details
-
close
public void close()Description copied from class:FileHandlerClose the currently open log file (if any).- Overrides:
closein classFileHandler
-
open
public void open()Description copied from class:FileHandlerOpen the new log file for the date specified bydate.- Overrides:
openin classFileHandler
-
publish
Description copied from class:FileHandlerFormat and publish aLogRecord.- Overrides:
publishin classFileHandler- Parameters:
record- description of the log event
-
publishInternal
Publishes a log record to the underlying handler.- Parameters:
record- The log record to publish
-