Save This Page
Home » apache-log4j-1.2.15 » org.apache » log4j » [javadoc | source]
org.apache.log4j
public class: AsyncAppender [javadoc | source]
java.lang.Object
   org.apache.log4j.AppenderSkeleton
      org.apache.log4j.AsyncAppender

All Implemented Interfaces:
    AppenderAttachable, OptionHandler, Appender

The AsyncAppender lets users log events asynchronously.

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 buffer.

Important note: The AsyncAppender can only be script configured using the org.apache.log4j.xml.DOMConfigurator .

Field Summary
public static final  int DEFAULT_BUFFER_SIZE    The default buffer size is set to 128 events. 
 AppenderAttachableImpl aai    Nested appenders. 
Fields inherited from org.apache.log4j.AppenderSkeleton:
layout,  name,  threshold,  errorHandler,  headFilter,  tailFilter,  closed
Constructor:
 public AsyncAppender() 
Method from org.apache.log4j.AsyncAppender Summary:
addAppender,   append,   close,   getAllAppenders,   getAppender,   getBlocking,   getBufferSize,   getLocationInfo,   isAttached,   removeAllAppenders,   removeAppender,   removeAppender,   requiresLayout,   setBlocking,   setBufferSize,   setLocationInfo
Methods from org.apache.log4j.AppenderSkeleton:
activateOptions,   addFilter,   append,   clearFilters,   doAppend,   finalize,   getErrorHandler,   getFilter,   getFirstFilter,   getLayout,   getName,   getThreshold,   isAsSevereAsThreshold,   setErrorHandler,   setLayout,   setName,   setThreshold
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.log4j.AsyncAppender Detail:
 public  void addAppender(Appender newAppender) 
    Add appender.
 public  void append(LoggingEvent event) 
    {@inheritDoc}
 public  void close() 
    Close this AsyncAppender by interrupting the dispatcher thread which will process all pending events before exiting.
 public Enumeration getAllAppenders() 
    Get iterator over attached appenders.
 public Appender getAppender(String name) 
    Get appender by name.
 public boolean getBlocking() 
    Gets whether appender should block calling thread when buffer is full. If false, messages will be counted by logger and a summary message appended after the contents of the buffer have been appended.
 public int getBufferSize() 
    Gets the current buffer size.
 public boolean getLocationInfo() 
    Gets whether the location of the logging request call should be captured.
 public boolean isAttached(Appender appender) 
    Determines if specified appender is attached.
 public  void removeAllAppenders() 
    Removes and closes all attached appenders.
 public  void removeAppender(Appender appender) 
    Removes an appender.
 public  void removeAppender(String name) 
    Remove appender by name.
 public boolean requiresLayout() 
    {@inheritDoc}
 public  void setBlocking(boolean value) 
    Sets whether appender should wait if there is no space available in the event buffer or immediately return.
 public  void setBufferSize(int size) 
    Sets the number of messages allowed in the event buffer before the calling thread is blocked (if blocking is true) or until messages are summarized and discarded. Changing the size will not affect messages already in the buffer.
 public  void setLocationInfo(boolean flag) 
    The LocationInfo option takes a boolean value. By default, it is set to false which means there will be no effort to extract the location information related to the event. As a result, the event that will be ultimately logged will likely to contain the wrong location information (if present in the log format).

    Location information extraction is comparatively very slow and should be avoided unless performance is not a concern.