Apache log4cxx  Version 0.11.0
AsyncAppender Class Reference

The AsyncAppender lets users log events asynchronously. More...

Inheritance diagram for AsyncAppender:
AppenderAttachable AppenderSkeleton Object Appender ObjectImpl OptionHandler Object Object

Public Member Functions

 AsyncAppender ()
 Create new instance. More...
 
virtual ~AsyncAppender ()
 Destructor. More...
 
void addRef () const
 
void releaseRef () const
 
void addAppender (const AppenderPtr &newAppender)
 Add appender. More...
 
virtual void doAppend (const spi::LoggingEventPtr &event, log4cxx::helpers::Pool &pool1)
 This method performs threshold checks and invokes filters before delegating actual logging to the subclasses specific AppenderSkeleton::append method. More...
 
void append (const spi::LoggingEventPtr &event, log4cxx::helpers::Pool &p)
 Subclasses of AppenderSkeleton should implement this method to perform actual logging. More...
 
void close ()
 Close this AsyncAppender by interrupting the dispatcher thread which will process all pending events before exiting. More...
 
AppenderList getAllAppenders () const
 Get iterator over attached appenders. More...
 
AppenderPtr getAppender (const LogString &name) const
 Get appender by name. More...
 
bool getLocationInfo () const
 Gets whether the location of the logging request call should be captured. More...
 
bool isAttached (const AppenderPtr &appender) const
 Determines if specified appender is attached. More...
 
virtual bool requiresLayout () const
 Configurators call this method to determine if the appender requires a layout. More...
 
void removeAllAppenders ()
 Removes and closes all attached appenders. More...
 
void removeAppender (const AppenderPtr &appender)
 Removes an appender. More...
 
void removeAppender (const LogString &name)
 Remove appender by name. More...
 
void setLocationInfo (bool flag)
 The LocationInfo attribute is provided for compatibility with log4j and has no effect on the log output. More...
 
void setBufferSize (int size)
 The BufferSize option takes a non-negative integer value. More...
 
int getBufferSize () const
 Gets the current buffer size. More...
 
void setBlocking (bool value)
 Sets whether appender should wait if there is no space available in the event buffer or immediately return. More...
 
bool getBlocking () const
 Gets whether appender should block calling thread when buffer is full. More...
 
void setOption (const LogString &option, const LogString &value)
 Set appender properties by name. More...
 
- Public Member Functions inherited from AppenderAttachable
virtual ~AppenderAttachable ()
 
- Public Member Functions inherited from Object
virtual const helpers::ClassgetClass () const
 
virtual ~Object ()
 
virtual bool instanceof (const Class &clazz) const =0
 
virtual const void * cast (const Class &clazz) const =0
 
- Public Member Functions inherited from AppenderSkeleton
 AppenderSkeleton ()
 
 AppenderSkeleton (const LayoutPtr &layout)
 
void finalize ()
 Finalize this appender by calling the derived class' close method. More...
 
virtual void activateOptions (log4cxx::helpers::Pool &)
 Derived appenders should override this method if option structure requires it. More...
 
void addFilter (const spi::FilterPtr &newFilter)
 Add a filter to end of the filter list. More...
 
void clearFilters ()
 Clear the filters chain. More...
 
const spi::ErrorHandlerPtrgetErrorHandler () const
 Return the currently set spi::ErrorHandler for this Appender. More...
 
spi::FilterPtr getFilter () const
 Returns the head Filter. More...
 
const spi::FilterPtrgetFirstFilter () const
 Return the first filter in the filter chain for this Appender. More...
 
LayoutPtr getLayout () const
 Returns the layout of this appender. More...
 
LogString getName () const
 Returns the name of this Appender. More...
 
const LevelPtrgetThreshold () const
 Returns this appenders threshold level. More...
 
bool isAsSevereAsThreshold (const LevelPtr &level) const
 Check whether the message level is below the appender's threshold. More...
 
void setErrorHandler (const spi::ErrorHandlerPtr &eh)
 Set the ErrorHandler for this Appender. More...
 
void setLayout (const LayoutPtr &layout1)
 Set the layout for this appender. More...
 
void setName (const LogString &name1)
 Set the name of this Appender. More...
 
void setThreshold (const LevelPtr &threshold)
 Set the threshold level. More...
 
- Public Member Functions inherited from Appender
virtual ~Appender ()
 
- Public Member Functions inherited from OptionHandler
virtual ~OptionHandler ()
 
- Public Member Functions inherited from ObjectImpl
 ObjectImpl ()
 
virtual ~ObjectImpl ()
 
void addRef () const
 
void releaseRef () const
 

Additional Inherited Members

- Static Public Member Functions inherited from Object
static const helpers::ClassgetStaticClass ()
 
static const log4cxx::helpers::ClassRegistrationregisterClass ()
 
- Protected Member Functions inherited from AppenderSkeleton
void doAppendImpl (const spi::LoggingEventPtr &event, log4cxx::helpers::Pool &pool)
 
- Protected Attributes inherited from AppenderSkeleton
LayoutPtr layout
 The layout variable does not need to be set if the appender implementation has its own layout. More...
 
LogString name
 Appenders are named. More...
 
LevelPtr threshold
 There is no level threshold filtering by default. More...
 
spi::ErrorHandlerPtr errorHandler
 It is assumed and enforced that errorHandler is never null. More...
 
spi::FilterPtr headFilter
 The first filter in the filter chain. More...
 
spi::FilterPtr tailFilter
 The last filter in the filter chain. More...
 
bool closed
 Is this appender closed? More...
 
log4cxx::helpers::Pool pool
 
SHARED_MUTEX mutex
 
- Protected Attributes inherited from ObjectImpl
unsigned int volatile ref
 

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.

Constructor & Destructor Documentation

Create new instance.

virtual ~AsyncAppender ( )
virtual

Destructor.

Member Function Documentation

void addAppender ( const AppenderPtr newAppender)
virtual

Add appender.

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

virtual void doAppend ( const spi::LoggingEventPtr event,
log4cxx::helpers::Pool pool 
)
virtual

This method performs threshold checks and invokes filters before delegating actual logging to the subclasses specific AppenderSkeleton::append method.

Reimplemented from AppenderSkeleton.

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
namename, 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
appenderappender.
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 AppenderPtr appender)
virtual

Removes an appender.

Parameters
appenderappender to remove.

Implements AppenderAttachable.

void removeAppender ( const LogString name)
virtual

Remove appender by name.

Parameters
namename.

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
valuetrue 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
flagnew value.
void setOption ( const LogString option,
const LogString value 
)
virtual

Set appender properties by name.

Parameters
optionproperty name.
valueproperty value.

Reimplemented from AppenderSkeleton.


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