AsyncAppender Class Reference

Inheritance diagram for AsyncAppender:

Inheritance graph
[legend]
Collaboration diagram for AsyncAppender:

Collaboration graph
[legend]
List of all members.

Public Member Functions

void addAppender (const AppenderPtr &newAppender)
void append (const spi::LoggingEventPtr &event)
void close ()
AppenderList getAllAppenders () const
AppenderPtr getAppender (const String &name) const
bool getLocationInfo () const
bool isAttached (const AppenderPtr &appender) const
void removeAllAppenders ()
void removeAppender (const AppenderPtr &appender)
void removeAppender (const String &name)
virtual bool requiresLayout () const
void setLocationInfo (bool flag)
void setBufferSize (int size)
int getBufferSize () const

Static Public Attributes

int DEFAULT_BUFFER_SIZE = 128

Detailed Description

The AsyncAppender lets users log events asynchronously. It uses a bounded buffer to store logging events.

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.

Important note: The AsyncAppender can only be script configured using the DOMConfigurator.


Member Function Documentation

void addAppender const AppenderPtr newAppender  )  [virtual]
 

Add an appender.

Implements AppenderAttachable.

void append const spi::LoggingEventPtr event  )  [virtual]
 

Subclasses of AppenderSkeleton should implement this method to perform actual logging. See also AppenderSkeleton::doAppend method.

Implements AppenderSkeleton.

void close  )  [virtual]
 

Close this AsyncAppender by interrupting the dispatcher thread which will process all pending events before exiting.

Implements Appender.

AppenderList getAllAppenders  )  const [virtual]
 

Get all previously added appenders as an AppenderList.

Implements AppenderAttachable.

AppenderPtr getAppender const String &  name  )  const [virtual]
 

Get an appender by name.

Implements AppenderAttachable.

int getBufferSize  )  const
 

Returns the current value of the BufferSize option.

bool getLocationInfo  )  const [inline]
 

Returns the current value of the LocationInfo option.

bool isAttached const AppenderPtr appender  )  const [virtual]
 

Is the appender passed as parameter attached to this asyncappender?

Implements AppenderAttachable.

void removeAllAppenders  )  [virtual]
 

Remove all previously added appenders.

Implements AppenderAttachable.

void removeAppender const String &  name  )  [virtual]
 

Remove the appender with the name passed as parameter from the list of appenders.

Implements AppenderAttachable.

void removeAppender const AppenderPtr appender  )  [virtual]
 

Remove the appender passed as parameter from the list of appenders.

Implements AppenderAttachable.

virtual bool requiresLayout  )  const [inline, virtual]
 

The AsyncAppender does not require a layout. Hence, this method always returns false.

Implements Appender.

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.

void setLocationInfo bool  flag  )  [inline]
 

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.


Member Data Documentation

int DEFAULT_BUFFER_SIZE = 128 [static]
 

The default buffer size is set to 128 events.


The documentation for this class was generated from the following files:
  • asyncappender.h
  • asyncappender.cpp

Copyright © 1999-2004, Apache Software Foundation