org.apache.log.output
Class MemoryTarget
- ErrorAware, LogTarget
public class MemoryTarget
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.
protected void | doProcessEvent(LogEvent event) - Process a log event, via formatting and outputting it.
|
boolean | isFull() - Check if memory buffer is full.
|
void | push() - Push log events to target.
|
protected void | setOverwrite(boolean overwrite) - Set flag indicating whether it is valid to overwrite memory buffer.
|
protected boolean | shouldPush(LogEvent event) - Determine if LogEvent should initiate a push to target.
|
MemoryTarget
public MemoryTarget(LogTarget target,
int size,
Priority threshold)
Creation of a new instance of the memory target.
target
- the target to push LogEvents tosize
- the event buffer sizethreshold
- the priority at which to push LogEvents to next LogTarget
isFull
public final boolean isFull()
Check if memory buffer is full.
- true if buffer is full, false otherwise
push
public void push()
Push log events to target.
setOverwrite
protected void setOverwrite(boolean overwrite)
Set flag indicating whether it is valid to overwrite memory buffer.
overwrite
- true if buffer should overwrite logevents in buffer, false otherwise
shouldPush
protected boolean shouldPush(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.
event
- the incoming LogEvent
- true if should push, false otherwise