Apache log4cxx  Version 0.10.0
AsyncAppender Class Reference

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

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

List of all members.

Classes

class  DiscardSummary

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.

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.

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:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines