- Main Page
- Modules
- Namespaces
- Classes
- Files

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# AsyncAppender Class Reference

Inherits AppenderAttachable, and AppenderSkeleton.

List of all members.

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

## Public Member Functions

| AsyncAppender ()
| Create new instance.
virtual | ~AsyncAppender ()
| Destructor.
void | addRef () const
void | releaseRef () const
void | addAppender (const AppenderPtr &newAppender)
| Add appender.
void | append (const spi::LoggingEventPtr &event, log4cxx::helpers::Pool &p)
| Subclasses of `AppenderSkeleton` should implement this method to perform actual logging.
void | close ()
| Close this `AsyncAppender` by interrupting the dispatcher thread which will process all pending events before exiting.
AppenderList | getAllAppenders () const
| Get iterator over attached appenders.
AppenderPtr | getAppender (const LogString &name) const
| Get appender by name.
bool | getLocationInfo () const
| Gets whether the location of the logging request call should be captured.
bool | isAttached (const AppenderPtr &appender) const
| Determines if specified appender is attached.
virtual bool | requiresLayout () const
| Configurators call this method to determine if the appender requires a layout.
void | removeAllAppenders ()
| Removes and closes all attached appenders.
void | removeAppender (const AppenderPtr &appender)
| Removes an appender.
void | removeAppender (const LogString &name)
| Remove appender by name.
void | setLocationInfo (bool flag)
| The LocationInfo attribute is provided for compatibility with log4j and has no effect on the log output.
void | setBufferSize (int size)
| The BufferSize option takes a non-negative integer value.
int | getBufferSize () const
| Gets the current buffer size.
void | setBlocking (bool value)
| Sets whether appender should wait if there is no space available in the event buffer or immediately return.
bool | getBlocking () const
| Gets whether appender should block calling thread when buffer is full.
void | setOption (const LogString &option, const LogString &value)
| Set appender properties by name.

## Classes

class | DiscardSummary

## Constructor & Destructor Documentation

AsyncAppender | ( |  | ) |

| Create new instance.

virtual ~AsyncAppender | ( |  | ) | `[virtual]`

| Destructor.

## Member Function Documentation

void addAppender | ( | const AppenderPtr & | newAppender | ) | `[virtual]`

| Add appender.

Parameters:

  | newAppender | appender to add, may not be null.

Implements AppenderAttachable.

void addRef | ( |  | ) | const`[virtual]`

| Reimplemented from AppenderSkeleton.

void append | ( | const spi::LoggingEventPtr & | event,
|  | log4cxx::helpers::Pool & | p
| ) | `[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 iterator over attached appenders.

Returns:
  list of all attached appenders.

Implements AppenderAttachable.

AppenderPtr getAppender | ( | const LogString & | name | ) | const`[virtual]`

| Get appender by name.

Parameters:

  | name | name, may not be null.

Returns:
  matching appender or null.

Implements AppenderAttachable.

bool getBlocking | ( |  | ) | const

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

Returns:
  true if calling thread will be blocked when buffer is full.

int getBufferSize | ( |  | ) | const

| Gets the current buffer size.

Returns:
  the current value of the BufferSize option.

bool getLocationInfo | ( |  | ) | const

| Gets whether the location of the logging request call should be captured.

Returns:
  the current value of the LocationInfo option.

bool isAttached | ( | const AppenderPtr & | appender | ) | const`[virtual]`

| Determines if specified appender is attached.

Parameters:

  | appender | appender.

Returns:
  true if attached.

Implements AppenderAttachable.

void releaseRef | ( |  | ) | const`[virtual]`

| Reimplemented from AppenderSkeleton.

void removeAllAppenders | ( |  | ) | `[virtual]`

| Removes and closes all attached appenders. Implements AppenderAttachable.

void removeAppender | ( | const LogString & | name | ) | `[virtual]`

| Remove appender by name.

Parameters:

  | name | name.

Implements AppenderAttachable.

void removeAppender | ( | const AppenderPtr & | appender | ) | `[virtual]`

| Removes an appender.

Parameters:

  | appender | appender to remove.

Implements AppenderAttachable.

virtual bool requiresLayout | ( |  | ) | const`[virtual]`

| Configurators call this method to determine if the appender requires a layout. If this method returns `true`, meaning that layout is required, then the configurator will configure an layout using the configuration information at its disposal. If this method returns `false`, meaning that a layout is not required, then layout configuration will be skipped even if there is available layout configuration information at the disposal of the configurator..

In the rather exceptional case, where the appender implementation admits a layout but can also work without it, then the appender should return `true`.

Implements Appender.

void setBlocking | ( | bool | value | ) |

| Sets whether appender should wait if there is no space available in the event buffer or immediately return.

Parameters:

  | value | true if appender should wait until available space in buffer.

void setBufferSize | ( | int | size | ) |

| The BufferSize option takes a non-negative integer value. This integer value determines the maximum size of the bounded buffer.

void setLocationInfo | ( | bool | flag | ) |

| The LocationInfo attribute is provided for compatibility with log4j and has no effect on the log output.

Parameters:

  | flag | new value.

void setOption | ( | const LogString & | option,
|  | const LogString & | value
| ) | `[virtual]`

| Set appender properties by name.

Parameters:

  | option | property name.
  | value | property value.

Reimplemented from AppenderSkeleton.

The documentation for this class was generated from the following file:

- asyncappender.h