ariba.util.log
Class AsyncAppender

java.lang.Object
  extended by org.apache.log4j.AppenderSkeleton
      extended by ariba.util.log.AsyncAppender
All Implemented Interfaces:
org.apache.log4j.Appender, org.apache.log4j.spi.OptionHandler

public class AsyncAppender
extends org.apache.log4j.AppenderSkeleton

Basically cloned from log4j's AsyncAppender in log4j 1.2.8. Unfortunately that class was not designed to be overridden from outside its package, so it had to be duplicated. Key differences to provide robustness and error accounting: 1) The Dispatcher call to appendLoopOnAppenders(event) is now in a try/catch block so if an exception occurs in the filtering or appending (processing) of the event it doesn't kill the dispatcher. 2) When the exceptions mentioned in (1) occur, they are captured by AsyncAppender and available externally (see the xxxMessage(s) methods, below).

See Also:
AsyncAppender

Field Summary
static int DEFAULT_BUFFER_SIZE
          The default buffer size is set to 128 events.
 
Constructor Summary
AsyncAppender(boolean isConsoleWriteSuspended)
           
 
Method Summary
 void addAppender(org.apache.log4j.Appender newAppender)
           
 void append(org.apache.log4j.spi.LoggingEvent event)
           
 void close()
          Close this AsyncAppender by interrupting the dispatcher thread which will process all pending events before exiting.
 java.util.Enumeration getAllAppenders()
           
 org.apache.log4j.Appender getAppender(java.lang.String name)
           
 int getBufferSize()
          Returns the current value of the BufferSize option.
 boolean getLocationInfo()
          Returns the current value of the LocationInfo option.
 boolean isAttached(org.apache.log4j.Appender appender)
          Is the appender passed as parameter attached to this category?
 void removeAllAppenders()
           
 void removeAppender(org.apache.log4j.Appender appender)
           
 void removeAppender(java.lang.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.
 
Methods inherited from class org.apache.log4j.AppenderSkeleton
activateOptions, addFilter, clearFilters, doAppend, finalize, getErrorHandler, getFilter, getFirstFilter, getLayout, getName, getThreshold, isAsSevereAsThreshold, setErrorHandler, setLayout, setName, setThreshold
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_BUFFER_SIZE

public static final int DEFAULT_BUFFER_SIZE
The default buffer size is set to 128 events.

See Also:
Constant Field Values
Constructor Detail

AsyncAppender

public AsyncAppender(boolean isConsoleWriteSuspended)
Method Detail

addAppender

public void addAppender(org.apache.log4j.Appender newAppender)

append

public void append(org.apache.log4j.spi.LoggingEvent event)
Specified by:
append in class org.apache.log4j.AppenderSkeleton

close

public void close()
Close this AsyncAppender by interrupting the dispatcher thread which will process all pending events before exiting.


getAllAppenders

public java.util.Enumeration getAllAppenders()

getAppender

public org.apache.log4j.Appender getAppender(java.lang.String name)

getLocationInfo

public boolean getLocationInfo()
Returns the current value of the LocationInfo option.


isAttached

public boolean isAttached(org.apache.log4j.Appender appender)
Is the appender passed as parameter attached to this category?


requiresLayout

public boolean requiresLayout()
The AsyncAppender does not require a layout. Hence, this method always returns false.


removeAllAppenders

public void removeAllAppenders()

removeAppender

public void removeAppender(org.apache.log4j.Appender appender)

removeAppender

public void removeAppender(java.lang.String name)

setLocationInfo

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.


setBufferSize

public void setBufferSize(int size)
The BufferSize option takes a non-negative integer value. This integer value determines the maximum size of the bounded buffer. Increasing the size of the buffer is always safe. However, if an existing buffer holds unwritten elements, then decreasing the buffer size will result in event loss. Nevertheless, while script configuring the AsyncAppender, it is safe to set a buffer size smaller than the default buffer size because configurators guarantee that an appender cannot be used before being completely configured.


getBufferSize

public int getBufferSize()
Returns the current value of the BufferSize option.



AribaWeb User Interface Development Framework
Copyright © 2000-2014 Ariba, Inc. All Rights Reserved.