Apache log4cxx  Version 0.12.0
log4cxx::AsyncAppender Class Reference

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

#include <asyncappender.h>

Inheritance diagram for log4cxx::AsyncAppender:
log4cxx::spi::AppenderAttachable log4cxx::AppenderSkeleton log4cxx::helpers::Object log4cxx::Appender log4cxx::helpers::Object log4cxx::spi::OptionHandler log4cxx::helpers::Object

Public Member Functions

 AsyncAppender ()
 Create new instance. More...
 
virtual ~AsyncAppender ()
 Destructor. More...
 
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 log4cxx::spi::AppenderAttachable
virtual ~AppenderAttachable ()
 
- Public Member Functions inherited from log4cxx::helpers::Object
virtual ~Object ()
 
virtual bool instanceof (const Class &clazz) const =0
 
virtual const void * cast (const Class &clazz) const =0
 
- Public Member Functions inherited from log4cxx::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 log4cxx::Appender
virtual ~Appender ()
 
void asdf ()
 
- Public Member Functions inherited from log4cxx::spi::OptionHandler
virtual ~OptionHandler ()
 

Additional Inherited Members

- Protected Member Functions inherited from log4cxx::AppenderSkeleton
void doAppendImpl (const spi::LoggingEventPtr &event, log4cxx::helpers::Pool &pool)
 
- Protected Attributes inherited from log4cxx::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
 
log4cxx::shared_mutex mutex
 

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

◆ AsyncAppender()

log4cxx::AsyncAppender::AsyncAppender ( )

Create new instance.

◆ ~AsyncAppender()

virtual log4cxx::AsyncAppender::~AsyncAppender ( )
virtual

Destructor.

Member Function Documentation

◆ addAppender()

void log4cxx::AsyncAppender::addAppender ( const AppenderPtr  newAppender)
virtual

Add appender.

Parameters
newAppenderappender to add, may not be null.

Implements log4cxx::spi::AppenderAttachable.

◆ append()

void log4cxx::AsyncAppender::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 log4cxx::AppenderSkeleton.

◆ close()

void log4cxx::AsyncAppender::close ( )
virtual

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

Implements log4cxx::Appender.

◆ doAppend()

virtual void log4cxx::AsyncAppender::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 log4cxx::AppenderSkeleton.

◆ getAllAppenders()

AppenderList log4cxx::AsyncAppender::getAllAppenders ( ) const
virtual

Get iterator over attached appenders.

Returns
list of all attached appenders.

Implements log4cxx::spi::AppenderAttachable.

◆ getAppender()

AppenderPtr log4cxx::AsyncAppender::getAppender ( const LogString name) const
virtual

Get appender by name.

Parameters
namename, may not be null.
Returns
matching appender or null.

Implements log4cxx::spi::AppenderAttachable.

◆ getBlocking()

bool log4cxx::AsyncAppender::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.

◆ getBufferSize()

int log4cxx::AsyncAppender::getBufferSize ( ) const

Gets the current buffer size.

Returns
the current value of the BufferSize option.

◆ getLocationInfo()

bool log4cxx::AsyncAppender::getLocationInfo ( ) const

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

Returns
the current value of the LocationInfo option.

◆ isAttached()

bool log4cxx::AsyncAppender::isAttached ( const AppenderPtr  appender) const
virtual

Determines if specified appender is attached.

Parameters
appenderappender.
Returns
true if attached.

Implements log4cxx::spi::AppenderAttachable.

◆ removeAllAppenders()

void log4cxx::AsyncAppender::removeAllAppenders ( )
virtual

Removes and closes all attached appenders.

Implements log4cxx::spi::AppenderAttachable.

◆ removeAppender() [1/2]

void log4cxx::AsyncAppender::removeAppender ( const AppenderPtr  appender)
virtual

Removes an appender.

Parameters
appenderappender to remove.

Implements log4cxx::spi::AppenderAttachable.

◆ removeAppender() [2/2]

void log4cxx::AsyncAppender::removeAppender ( const LogString name)
virtual

Remove appender by name.

Parameters
namename.

Implements log4cxx::spi::AppenderAttachable.

◆ requiresLayout()

virtual bool log4cxx::AsyncAppender::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 log4cxx::Appender.

◆ setBlocking()

void log4cxx::AsyncAppender::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.

◆ setBufferSize()

void log4cxx::AsyncAppender::setBufferSize ( int  size)

The BufferSize option takes a non-negative integer value.

This integer value determines the maximum size of the bounded buffer.

◆ setLocationInfo()

void log4cxx::AsyncAppender::setLocationInfo ( bool  flag)

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

Parameters
flagnew value.

◆ setOption()

void log4cxx::AsyncAppender::setOption ( const LogString option,
const LogString value 
)
virtual

Set appender properties by name.

Parameters
optionproperty name.
valueproperty value.

Reimplemented from log4cxx::AppenderSkeleton.


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