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

public Class MemoryTarget

extends AbstractTarget
Class Inheritance
Imports
org.apache.log.LogEvent, .LogTarget, .Priority

Output LogEvents into an buffer in memory. At a later stage these LogEvents can be forwarded or pushed to another target. This pushing is triggered when buffer is full, the priority of a LogEvent reaches a threshold or when another class calls the push method. This is based on specification of MemoryHandler in Logging JSR47.
Authors
Avalon Development Team, Peter Donald

Field Summary

Modifier and TypeField and Description
private final LogEvent[]
private int
private boolean
private LogTarget
private Priority
private int

Constructor Summary

AccessConstructor and Description
public
MemoryTarget(final LogTarget
the target to push LogEvents to
target
,
final int
the event buffer size
size
,
final Priority
the priority at which to push LogEvents to next LogTarget
threshold
)

Creation of a new instance of the memory target.

Method Summary

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

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

Process a log event, via formatting and outputting it.
public final synchronized boolean

Returns:

true if buffer is full, false otherwise
isFull
()

Check if memory buffer is full.

public synchronized void
push()

Push log events to target.

protected synchronized void
setOverwrite(final boolean
true if buffer should overwrite logevents in buffer, false otherwise
overwrite
)

Set flag indicating whether it is valid to overwrite memory buffer.

protected synchronized boolean

Returns:

true if should push, false otherwise
shouldPush
(final LogEvent
the incoming LogEvent
event
)

Determine if LogEvent should initiate a push to target.

Inherited from org.apache.log.output.AbstractTarget:
closegetErrorHandlerisOpenopenprocessEventsetErrorHandler

Field Detail

m_bufferback to summary
private final LogEvent[] m_buffer
m_indexback to summary
private int m_index
m_overwriteback to summary
private boolean m_overwrite
m_targetback to summary
private LogTarget m_target
m_thresholdback to summary
private Priority m_threshold
m_usedback to summary
private int m_used

Constructor Detail

MemoryTargetback to summary
public MemoryTarget(final LogTarget target, final int size, final Priority threshold)

Creation of a new instance of the memory target.

Parameters
target:LogTarget

the target to push LogEvents to

size:int

the event buffer size

threshold:Priority

the priority at which to push LogEvents to next LogTarget

Method Detail

doProcessEventback to summary
protected synchronized void doProcessEvent(final LogEvent event)

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

Process a log event, via formatting and outputting it.

Parameters
event:LogEvent

the log event

isFullback to summary
public final synchronized boolean isFull()

Check if memory buffer is full.

Returns:boolean

true if buffer is full, false otherwise

pushback to summary
public synchronized void push()

Push log events to target.

setOverwriteback to summary
protected synchronized void setOverwrite(final boolean overwrite)

Set flag indicating whether it is valid to overwrite memory buffer.

Parameters
overwrite:boolean

true if buffer should overwrite logevents in buffer, false otherwise

shouldPushback to summary
protected synchronized boolean shouldPush(final LogEvent event)

Determine if LogEvent should initiate a push to target. Subclasses can overide this method to change the conditions under which a push occurs.

Parameters
event:LogEvent

the incoming LogEvent

Returns:boolean

true if should push, false otherwise