Package org.apache.log.output
Class AsyncLogTarget
java.lang.Object
org.apache.log.output.AbstractTarget
org.apache.log.output.AbstractWrappingTarget
org.apache.log.output.AsyncLogTarget
- All Implemented Interfaces:
Runnable,ErrorAware,LogTarget,Closeable
An asynchronous LogTarget that sends entries on in another thread.
It is the responsibility of the user of this class to start
the thread etc.
LogTarget mySlowTarget = ...;
AsyncLogTarget asyncTarget = new AsyncLogTarget( mySlowTarget );
Thread thread = new Thread( asyncTarget );
thread.setPriority( Thread.MIN_PRIORITY );
thread.start();
logger.setLogTargets( new LogTarget[] { asyncTarget } );
- Author:
- Avalon Development Team, Peter Donald
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAsyncLogTarget(LogTarget logTarget) Creation of a new async log target.AsyncLogTarget(LogTarget logTarget, boolean closeTarget) Creation of a new async log target.AsyncLogTarget(LogTarget logTarget, int queueSize) Creation of a new async log target.AsyncLogTarget(LogTarget logTarget, int queueSize, boolean closeTarget) Creation of a new async log target. -
Method Summary
Modifier and TypeMethodDescriptionvoiddoProcessEvent(LogEvent event) Process a log event by adding it to queue.voidrun()Thread startup.voidsetErrorHandler(ErrorHandler errorHandler) Provide component with ErrorHandler.Methods inherited from class org.apache.log.output.AbstractWrappingTarget
close, getLogTargetMethods inherited from class org.apache.log.output.AbstractTarget
getErrorHandler, isOpen, open, processEvent
-
Field Details
-
m_list
-
m_queueSize
private final int m_queueSize
-
-
Constructor Details
-
AsyncLogTarget
Creation of a new async log target.- Parameters:
logTarget- the underlying target
-
AsyncLogTarget
Creation of a new async log target.- Parameters:
logTarget- the underlying targetqueueSize- the queue size
-
AsyncLogTarget
Creation of a new async log target.- Parameters:
logTarget- the underlying targetcloseTarget- close the underlying target when this target is closed. This flag has no effect unless the logTarget implements Closeable.
-
AsyncLogTarget
Creation of a new async log target.- Parameters:
logTarget- the underlying targetqueueSize- the queue sizecloseTarget- close the underlying target when this target is closed. This flag has no effect unless the logTarget implements Closeable.
-
-
Method Details
-
setErrorHandler
Provide component with ErrorHandler.- Specified by:
setErrorHandlerin interfaceErrorAware- Overrides:
setErrorHandlerin classAbstractTarget- Parameters:
errorHandler- the errorHandler
-
doProcessEvent
Process a log event by adding it to queue.- Specified by:
doProcessEventin classAbstractTarget- Parameters:
event- the log event
-
run
public void run()Thread startup.
-