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:
java.lang.Runnable
,ErrorAware
,LogTarget
,Closeable
public class AsyncLogTarget extends AbstractWrappingTarget implements java.lang.Runnable
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 } );
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.LinkedList
m_list
private int
m_queueSize
-
Constructor Summary
Constructors Constructor Description AsyncLogTarget(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
doProcessEvent(LogEvent event)
Process a log event by adding it to queue.void
run()
Thread startup.void
setErrorHandler(ErrorHandler errorHandler)
Provide component with ErrorHandler.-
Methods inherited from class org.apache.log.output.AbstractWrappingTarget
close, getLogTarget
-
Methods inherited from class org.apache.log.output.AbstractTarget
getErrorHandler, isOpen, open, processEvent
-
-
-
-
Constructor Detail
-
AsyncLogTarget
public AsyncLogTarget(LogTarget logTarget)
Creation of a new async log target.- Parameters:
logTarget
- the underlying target
-
AsyncLogTarget
public AsyncLogTarget(LogTarget logTarget, int queueSize)
Creation of a new async log target.- Parameters:
logTarget
- the underlying targetqueueSize
- the queue size
-
AsyncLogTarget
public AsyncLogTarget(LogTarget logTarget, boolean closeTarget)
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
public AsyncLogTarget(LogTarget logTarget, int queueSize, boolean closeTarget)
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 Detail
-
setErrorHandler
public void setErrorHandler(ErrorHandler errorHandler)
Provide component with ErrorHandler.- Specified by:
setErrorHandler
in interfaceErrorAware
- Overrides:
setErrorHandler
in classAbstractTarget
- Parameters:
errorHandler
- the errorHandler
-
doProcessEvent
public void doProcessEvent(LogEvent event)
Process a log event by adding it to queue.- Specified by:
doProcessEvent
in classAbstractTarget
- Parameters:
event
- the log event
-
run
public void run()
Thread startup.- Specified by:
run
in interfacejava.lang.Runnable
-
-