Apache Log4cxx Version 1.0.0
|
The AsyncAppender lets users log events asynchronously. More...
#include <asyncappender.h>
Public Member Functions | |
AsyncAppender () | |
Create new instance. | |
virtual | ~AsyncAppender () |
Destructor. | |
void | addAppender (const AppenderPtr newAppender) override |
Add appender. | |
void | doAppend (const spi::LoggingEventPtr &event, helpers::Pool &pool1) override |
This method performs threshold checks and invokes filters before delegating actual logging to the subclasses specific AppenderSkeleton::append method. | |
void | append (const spi::LoggingEventPtr &event, helpers::Pool &p) override |
Subclasses of AppenderSkeleton should implement this method to perform actual logging. | |
void | close () override |
Close this AsyncAppender by interrupting the dispatcher thread which will process all pending events before exiting. | |
AppenderList | getAllAppenders () const override |
Get iterator over attached appenders. | |
AppenderPtr | getAppender (const LogString &name) const override |
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 override |
Determines if specified appender is attached. | |
bool | requiresLayout () const override |
Configurators call this method to determine if the appender requires a layout. | |
void | removeAllAppenders () override |
Removes and closes all attached appenders. | |
void | removeAppender (const AppenderPtr appender) override |
Removes an appender. | |
void | removeAppender (const LogString &name) override |
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) override |
Set appender properties by name. | |
Public Member Functions inherited from log4cxx::spi::AppenderAttachable | |
virtual void | addAppender (const AppenderPtr newAppender)=0 |
Add an appender. | |
virtual AppenderList | getAllAppenders () const =0 |
Get all previously added appenders as an AppenderList. | |
virtual AppenderPtr | getAppender (const LogString &name) const =0 |
Get an appender by name. | |
virtual bool | isAttached (const AppenderPtr appender) const =0 |
Returns true if the specified appender is in list of attached appenders, false otherwise. | |
virtual void | removeAllAppenders ()=0 |
Remove all previously added appenders. | |
virtual void | removeAppender (const AppenderPtr appender)=0 |
Remove the appender passed as parameter from the list of appenders. | |
virtual void | removeAppender (const LogString &name)=0 |
Remove the appender with the name passed as parameter from the list of appenders. | |
virtual | ~AppenderAttachable () |
Public Member Functions inherited from log4cxx::helpers::Object | |
virtual | ~Object () |
virtual const helpers::Class & | getClass () const =0 |
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) | |
virtual | ~AppenderSkeleton () |
void | finalize () |
Finalize this appender by calling the derived class' close method. | |
void | activateOptions (helpers::Pool &) override |
Derived appenders should override this method if option structure requires it. | |
void | setOption (const LogString &option, const LogString &value) override |
Set option to value . | |
void | addFilter (const spi::FilterPtr newFilter) override |
Add a filter to end of the filter list. | |
void | clearFilters () override |
Clear the filters chain. | |
const spi::ErrorHandlerPtr | getErrorHandler () const |
Return the currently set spi::ErrorHandler for this Appender. | |
spi::FilterPtr | getFilter () const override |
Returns the head Filter. | |
const spi::FilterPtr | getFirstFilter () const |
Return the first filter in the filter chain for this Appender. | |
LayoutPtr | getLayout () const override |
Returns the layout of this appender. | |
LogString | getName () const override |
Returns the name of this Appender. | |
const LevelPtr | getThreshold () const |
Returns this appenders threshold level. | |
bool | isAsSevereAsThreshold (const LevelPtr &level) const |
Check whether the message level is below the appender's threshold. | |
void | doAppend (const spi::LoggingEventPtr &event, helpers::Pool &pool) override |
This method performs threshold checks and invokes filters before delegating actual logging to the subclasses specific AppenderSkeleton::append method. | |
void | setErrorHandler (const spi::ErrorHandlerPtr eh) |
Set the ErrorHandler for this Appender. | |
void | setLayout (const LayoutPtr layout1) override |
Set the layout for this appender. | |
void | setName (const LogString &name1) override |
Set the name of this Appender. | |
void | setThreshold (const LevelPtr &threshold) |
Set the threshold level. | |
Public Member Functions inherited from log4cxx::Appender | |
virtual | ~Appender () |
virtual void | addFilter (const spi::FilterPtr newFilter)=0 |
Add a filter to the end of the filter list. | |
virtual spi::FilterPtr | getFilter () const =0 |
Returns the head Filter. | |
virtual void | clearFilters ()=0 |
Clear the list of filters by removing all the filters in it. | |
virtual void | close ()=0 |
Release any resources allocated within the appender such as file handles, network connections, etc. | |
virtual void | doAppend (const spi::LoggingEventPtr &event, log4cxx::helpers::Pool &pool)=0 |
Log in Appender specific way. | |
virtual LogString | getName () const =0 |
Get the name of this appender. | |
virtual void | setLayout (const LayoutPtr layout)=0 |
Set the Layout for this appender. | |
virtual LayoutPtr | getLayout () const =0 |
Returns this appenders layout. | |
virtual void | setName (const LogString &name)=0 |
Set the name of this appender. | |
virtual bool | requiresLayout () const =0 |
Configurators call this method to determine if the appender requires a layout. | |
Public Member Functions inherited from log4cxx::spi::OptionHandler | |
virtual | ~OptionHandler () |
virtual void | activateOptions (helpers::Pool &p)=0 |
Activate the options that were previously set with calls to option setters. | |
virtual void | setOption (const LogString &option, const LogString &value)=0 |
Set option to value . | |
Additional Inherited Members | |
Protected Member Functions inherited from log4cxx::AppenderSkeleton | |
AppenderSkeleton (LOG4CXX_PRIVATE_PTR(AppenderSkeletonPrivate) priv) | |
virtual void | append (const spi::LoggingEventPtr &event, log4cxx::helpers::Pool &p)=0 |
Subclasses of AppenderSkeleton should implement this method to perform actual logging. | |
void | doAppendImpl (const spi::LoggingEventPtr &event, log4cxx::helpers::Pool &pool) |
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
.
log4cxx::AsyncAppender::AsyncAppender | ( | ) |
Create new instance.
|
virtual |
Destructor.
|
overridevirtual |
Add appender.
newAppender | appender to add, may not be null. |
Implements log4cxx::spi::AppenderAttachable.
|
overridevirtual |
Subclasses of AppenderSkeleton
should implement this method to perform actual logging.
See also AppenderSkeleton::doAppend method.
Implements log4cxx::AppenderSkeleton.
|
overridevirtual |
Close this AsyncAppender
by interrupting the dispatcher thread which will process all pending events before exiting.
Implements log4cxx::Appender.
|
overridevirtual |
This method performs threshold checks and invokes filters before delegating actual logging to the subclasses specific AppenderSkeleton::append method.
Reimplemented from log4cxx::AppenderSkeleton.
|
overridevirtual |
Get iterator over attached appenders.
Implements log4cxx::spi::AppenderAttachable.
|
overridevirtual |
Get appender by name.
name | name, may not be null. |
Implements log4cxx::spi::AppenderAttachable.
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.
int log4cxx::AsyncAppender::getBufferSize | ( | ) | const |
Gets the current buffer size.
bool log4cxx::AsyncAppender::getLocationInfo | ( | ) | const |
Gets whether the location of the logging request call should be captured.
|
overridevirtual |
Determines if specified appender is attached.
appender | appender. |
Implements log4cxx::spi::AppenderAttachable.
|
overridevirtual |
Removes and closes all attached appenders.
Implements log4cxx::spi::AppenderAttachable.
|
overridevirtual |
Removes an appender.
appender | appender to remove. |
Implements log4cxx::spi::AppenderAttachable.
|
overridevirtual |
|
overridevirtual |
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.
void log4cxx::AsyncAppender::setBlocking | ( | bool | value | ) |
Sets whether appender should wait if there is no space available in the event buffer or immediately return.
value | true if appender should wait until available space in buffer. |
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.
void log4cxx::AsyncAppender::setLocationInfo | ( | bool | flag | ) |
The LocationInfo attribute is provided for compatibility with log4j and has no effect on the log output.
flag | new value. |
|
overridevirtual |
Set appender properties by name.
option | property name. |
value | property value. |
Reimplemented from log4cxx::AppenderSkeleton.