An implementation of
Handler that queues log records and handles
them in the background. The log records are processed in the order received,
regardless of level.
- AO Industries, Inc.
Method SummaryModifier and TypeMethodDescription
protected abstract voidThis is called in a background thread.
flush()TODO: Could wait until all queued log records up to this moment have been handled.
protected static ExecutorServiceCreates a new executor.
protected static voidShuts down the executor, waiting up to one minute for tasks to complete.
Methods inherited from class java.util.logging.Handler
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError, setEncoding, setErrorManager, setFilter, setFormatter, setLevel
(String executorThreadName)Manages the queue internally.
(ExecutorService executor)Uses the provided executor. The executor is not shutdown on
close(); it is up to the caller to manage the executor lifecycle.
newExecutorCreates a new executor. Must be shutdown when no longer needed.
shutdownExecutorShuts down the executor, waiting up to one minute for tasks to complete.
publishpublic void publish
- Specified by:
- See Also:
flushpublic void flush()TODO: Could wait until all queued log records up to this moment have been handled. If new log records are added while we wait, don't wait for them.
closepublic void close() throws SecurityException
backgroundPublishprotected abstract void backgroundPublish
(Formatter formatter, LogRecord rec, String fullReport) throws ExceptionThis is called in a background thread.
formatter- the formatter at the time the record was queued
rec- the queued record
fullReport- the complete message generated by the formatter before the record was queued. The message is generated before so it can have accurate thread and time information.