Top Description Fields Constructors Methods
org.apache.log.output

public Class AsyncLogTarget

extends AbstractWrappingTarget
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable
Imports
java.util.LinkedList, org.apache.log.ErrorAware, .ErrorHandler, .LogEvent, .LogTarget

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 } );
Authors
Avalon Development Team, Peter Donald

Field Summary

Modifier and TypeField and Description
private final LinkedList<E>
private final int

Constructor Summary

AccessConstructor and Description
public
AsyncLogTarget(final LogTarget
the underlying target
logTarget
)

Creation of a new async log target.

public
AsyncLogTarget(final LogTarget
the underlying target
logTarget
,
final int
the queue size
queueSize
)

Creation of a new async log target.

public
AsyncLogTarget(final LogTarget
the underlying target
logTarget
,
final boolean
close the underlying target when this target is closed. This flag has no effect unless the logTarget implements Closeable.
closeTarget
)

Creation of a new async log target.

public
AsyncLogTarget(final LogTarget
the underlying target
logTarget
,
final int
the queue size
queueSize
,
final boolean
close the underlying target when this target is closed. This flag has no effect unless the logTarget implements Closeable.
closeTarget
)

Creation of a new async log target.

Method Summary

Modifier and TypeMethod and Description
public void
doProcessEvent(final LogEvent
the log event
event
)

Implements abstract org.apache.log.output.AbstractTarget.doProcessEvent.

Process a log event by adding it to queue.
public void
run()

Implements java.lang.Runnable.run.

Thread startup.
public synchronized void
setErrorHandler(final ErrorHandler
the errorHandler
errorHandler
)

Overrides org.apache.log.output.AbstractTarget.setErrorHandler.

Implements org.apache.log.ErrorAware.setErrorHandler.

Provide component with ErrorHandler.
Inherited from org.apache.log.output.AbstractWrappingTarget:
closegetLogTarget

Field Detail

m_listback to summary
private final LinkedList<E> m_list
m_queueSizeback to summary
private final int m_queueSize

Constructor Detail

AsyncLogTargetback to summary
public AsyncLogTarget(final LogTarget logTarget)

Creation of a new async log target.

Parameters
logTarget:LogTarget

the underlying target

AsyncLogTargetback to summary
public AsyncLogTarget(final LogTarget logTarget, final int queueSize)

Creation of a new async log target.

Parameters
logTarget:LogTarget

the underlying target

queueSize:int

the queue size

AsyncLogTargetback to summary
public AsyncLogTarget(final LogTarget logTarget, final boolean closeTarget)

Creation of a new async log target.

Parameters
logTarget:LogTarget

the underlying target

closeTarget:boolean

close the underlying target when this target is closed. This flag has no effect unless the logTarget implements Closeable.

AsyncLogTargetback to summary
public AsyncLogTarget(final LogTarget logTarget, final int queueSize, final boolean closeTarget)

Creation of a new async log target.

Parameters
logTarget:LogTarget

the underlying target

queueSize:int

the queue size

closeTarget:boolean

close the underlying target when this target is closed. This flag has no effect unless the logTarget implements Closeable.

Method Detail

doProcessEventback to summary
public void doProcessEvent(final LogEvent event)

Implements abstract org.apache.log.output.AbstractTarget.doProcessEvent.

Process a log event by adding it to queue.

Parameters
event:LogEvent

the log event

runback to summary
public void run()

Implements java.lang.Runnable.run.

Thread startup.

setErrorHandlerback to summary
public synchronized void setErrorHandler(final ErrorHandler errorHandler)

Overrides org.apache.log.output.AbstractTarget.setErrorHandler.

Implements org.apache.log.ErrorAware.setErrorHandler.

Provide component with ErrorHandler.

Parameters
errorHandler:ErrorHandler

the errorHandler