org.apache.log4j
public class AsyncAppender extends AppenderSkeleton implements AppenderAttachable
The AsyncAppender will collect the events sent to it and then dispatch them to all the appenders that are attached to it. You can attach multiple appenders to an AsyncAppender.
The AsyncAppender uses a separate thread to serve the events in its bounded buffer.
Refer to the results in {@link org.apache.log4j.performance.Logging} for the impact of using this appender.
Important note: The AsyncAppender
can only
be script configured using the {@link
org.apache.log4j.xml.DOMConfigurator}.
Since: 0.9.1
Field Summary | |
---|---|
static int | DEFAULT_BUFFER_SIZE The default buffer size is set to 128 events. |
Constructor Summary | |
---|---|
AsyncAppender() |
Method Summary | |
---|---|
void | addAppender(Appender newAppender) |
void | append(LoggingEvent event) |
void | close()
Close this AsyncAppender by interrupting the
dispatcher thread which will process all pending events before
exiting. |
Enumeration | getAllAppenders() |
Appender | getAppender(String name) |
int | getBufferSize()
Returns the current value of the BufferSize option. |
boolean | getLocationInfo()
Returns the current value of the LocationInfo option. |
boolean | isAttached(Appender appender)
Is the appender passed as parameter attached to this category? |
void | removeAllAppenders() |
void | removeAppender(Appender appender) |
void | removeAppender(String name) |
boolean | requiresLayout()
The AsyncAppender does not require a layout. |
void | setBufferSize(int size)
The BufferSize option takes a non-negative integer value.
|
void | setLocationInfo(boolean flag)
The LocationInfo option takes a boolean value. |
AsyncAppender
by interrupting the
dispatcher thread which will process all pending events before
exiting.AsyncAppender
does not require a layout. Hence,
this method always returns false
.Location information extraction is comparatively very slow and should be avoided unless performance is not a concern.