org.apache.log.output
public class AsyncLogTarget extends AbstractWrappingTarget implements Runnable
LogTarget mySlowTarget = ...; AsyncLogTarget asyncTarget = new AsyncLogTarget( mySlowTarget ); Thread thread = new Thread( asyncTarget ); thread.setPriority( Thread.MIN_PRIORITY ); thread.start(); logger.setLogTargets( new LogTarget[] { asyncTarget } );
Modifier and Type | Field and Description |
---|---|
private LinkedList |
m_list |
private int |
m_queueSize |
Constructor and 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.
|
Modifier and Type | Method and 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.
|
close, getLogTarget
getErrorHandler, isOpen, open, processEvent
private final LinkedList m_list
private final int m_queueSize
public AsyncLogTarget(LogTarget logTarget)
logTarget
- the underlying targetpublic AsyncLogTarget(LogTarget logTarget, int queueSize)
logTarget
- the underlying targetqueueSize
- the queue sizepublic AsyncLogTarget(LogTarget logTarget, boolean closeTarget)
logTarget
- the underlying targetcloseTarget
- close the underlying target when this target is closed. This flag
has no effect unless the logTarget implements Closeable.public AsyncLogTarget(LogTarget logTarget, int queueSize, boolean closeTarget)
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.public void setErrorHandler(ErrorHandler errorHandler)
setErrorHandler
in interface ErrorAware
setErrorHandler
in class AbstractTarget
errorHandler
- the errorHandlerpublic void doProcessEvent(LogEvent event)
doProcessEvent
in class AbstractTarget
event
- the log eventCopyright © 2003-2004 The Apache Software Foundation. All Rights Reserved.