log4cplus
2.1.0
|
Extend this class for implementing your own strategies for printing log statements. More...
#include <appender.h>
Public Member Functions | |
Appender () | |
Appender (const log4cplus::helpers::Properties &properties) | |
virtual | ~Appender () |
void | destructorImpl () |
This function is for derived appenders to call from their destructors. More... | |
virtual void | close ()=0 |
Release any resources allocated within the appender such as file handles, network connections, etc. More... | |
bool | isClosed () const |
Check if this appender is in closed state. More... | |
void | syncDoAppend (const log4cplus::spi::InternalLoggingEvent &event) |
This method performs threshold checks and invokes filters before delegating actual logging to the subclasses specific {} method. More... | |
void | asyncDoAppend (const log4cplus::spi::InternalLoggingEvent &event) |
This method performs book keeping related to asynchronous logging and executes syncDoAppend() to do the actual logging. More... | |
void | doAppend (const log4cplus::spi::InternalLoggingEvent &event) |
This function checks async flag. More... | |
virtual log4cplus::tstring | getName () |
Get the name of this appender. More... | |
virtual void | setName (const log4cplus::tstring &name) |
Set the name of this appender. More... | |
virtual void | setErrorHandler (std::unique_ptr< ErrorHandler > eh) |
Set the ErrorHandler for this Appender. More... | |
virtual ErrorHandler * | getErrorHandler () |
Return the currently set ErrorHandler for this Appender. More... | |
virtual void | setLayout (std::unique_ptr< Layout > layout) |
Set the layout for this appender. More... | |
virtual Layout * | getLayout () |
Returns the layout of this appender. More... | |
void | setFilter (log4cplus::spi::FilterPtr f) |
Set the filter chain on this Appender. More... | |
log4cplus::spi::FilterPtr | getFilter () const |
Get the filter chain on this Appender. More... | |
void | addFilter (log4cplus::spi::FilterPtr f) |
Add filter at the end of the filters chain. More... | |
void | addFilter (std::function< spi::FilterResult(const log4cplus::spi::InternalLoggingEvent &)>) |
Add filter at the end of the filters chain. More... | |
LogLevel | getThreshold () const |
Returns this appenders threshold LogLevel. More... | |
void | setThreshold (LogLevel th) |
Set the threshold LogLevel. More... | |
bool | isAsSevereAsThreshold (LogLevel ll) const |
Check whether the message LogLevel is below the appender's threshold. More... | |
void | waitToFinishAsyncLogging () |
This method waits for all events that are being asynchronously logged to finish. More... | |
Public Member Functions inherited from log4cplus::helpers::SharedObject | |
void | addReference () const LOG4CPLUS_NOEXCEPT |
void | removeReference () const |
Protected Member Functions | |
virtual void | append (const log4cplus::spi::InternalLoggingEvent &event)=0 |
Subclasses of Appender should implement this method to perform actual logging. More... | |
tstring & | formatEvent (const log4cplus::spi::InternalLoggingEvent &event) const |
Protected Member Functions inherited from log4cplus::helpers::SharedObject | |
SharedObject () | |
SharedObject (const SharedObject &) | |
SharedObject (SharedObject &&) | |
virtual | ~SharedObject () |
SharedObject & | operator= (const SharedObject &) LOG4CPLUS_NOEXCEPT |
SharedObject & | operator= (SharedObject &&) LOG4CPLUS_NOEXCEPT |
Protected Attributes | |
std::unique_ptr< Layout > | layout |
The layout variable does not need to be set if the appender implementation has its own layout. More... | |
log4cplus::tstring | name |
Appenders are named. More... | |
LogLevel | threshold |
There is no LogLevel threshold filtering by default. More... | |
log4cplus::spi::FilterPtr | filter |
The first filter in the filter chain. More... | |
std::unique_ptr< ErrorHandler > | errorHandler |
It is assumed and enforced that errorHandler is never null. More... | |
std::unique_ptr< helpers::LockFile > | lockFile |
Optional system wide synchronization lock. More... | |
bool | useLockFile |
Use lock file for inter-process synchronization of access to log file. More... | |
bool | async |
Asynchronous append. More... | |
std::atomic< std::size_t > | in_flight |
std::mutex | in_flight_mutex |
std::condition_variable | in_flight_condition |
bool | closed |
Is this appender closed? More... | |
Additional Inherited Members | |
Public Attributes inherited from log4cplus::helpers::SharedObject | |
thread::Mutex | access_mutex |
Extend this class for implementing your own strategies for printing log statements.
layout
filters
This property specifies possibly multiple filters used by Appender. Each of multple filters and its properties is under a numbered subkey of filters key. E.g.: filters.1=log4cplus::spi::LogLevelMatchFilter
. Filter subkey numbers must be consecutive.
Threshold
This property specifies log level threshold. Events with lower log level than the threshold will not be logged by appender.
UseLockFile
true
if you want your output through this appender to be synchronized between multiple processes. When this property is set to true then log4cplus uses OS specific facilities (e.g., lockf()
) to provide inter-process locking. With the exception of FileAppender and its derived classes, it is also necessary to provide path to a lock file using the LockFile
property. LockFile
UseLockFile
is set to true. Then it is mandatory. AsyncAppend
Set this property to true
if you want all appends using this appender to be done asynchronously. Default is false
.
Definition at line 137 of file appender.h.
log4cplus::Appender::Appender | ( | ) |
log4cplus::Appender::Appender | ( | const log4cplus::helpers::Properties & | properties | ) |
|
virtual |
void log4cplus::Appender::addFilter | ( | log4cplus::spi::FilterPtr | f | ) |
Add filter at the end of the filters chain.
void log4cplus::Appender::addFilter | ( | std::function< spi::FilterResult(const log4cplus::spi::InternalLoggingEvent &)> | ) |
Add filter at the end of the filters chain.
|
protectedpure virtual |
Subclasses of Appender
should implement this method to perform actual logging.
Implemented in log4cplus::Win32ConsoleAppender, log4cplus::Qt5DebugAppender, log4cplus::Qt4DebugAppender, log4cplus::MSTTSAppender, log4cplus::CLFSAppender, log4cplus::AsyncAppender, log4cplus::DeviceAppender< Device >, log4cplus::SysLogAppender, log4cplus::SocketAppender, log4cplus::NTEventLogAppender, log4cplus::Log4jUdpAppender, log4cplus::TimeBasedRollingFileAppender, log4cplus::DailyRollingFileAppender, log4cplus::RollingFileAppender, log4cplus::FileAppenderBase, log4cplus::ConsoleAppender, log4cplus::NullAppender, and log4cplus::CallbackAppender.
void log4cplus::Appender::asyncDoAppend | ( | const log4cplus::spi::InternalLoggingEvent & | event | ) |
This method performs book keeping related to asynchronous logging and executes syncDoAppend()
to do the actual logging.
|
pure virtual |
Release any resources allocated within the appender such as file handles, network connections, etc.
It is a programming error to append to a closed appender.
Implemented in log4cplus::Win32ConsoleAppender, log4cplus::SysLogAppender, log4cplus::SocketAppender, log4cplus::Qt5DebugAppender, log4cplus::Qt4DebugAppender, log4cplus::NullAppender, log4cplus::NTEventLogAppender, log4cplus::MSTTSAppender, log4cplus::Log4jUdpAppender, log4cplus::TimeBasedRollingFileAppender, log4cplus::DailyRollingFileAppender, log4cplus::FileAppenderBase, log4cplus::ConsoleAppender, log4cplus::CLFSAppender, log4cplus::CallbackAppender, log4cplus::DeviceAppender< Device >, and log4cplus::AsyncAppender.
void log4cplus::Appender::destructorImpl | ( | ) |
void log4cplus::Appender::doAppend | ( | const log4cplus::spi::InternalLoggingEvent & | event | ) |
This function checks async
flag.
It either executes syncDoAppend()
directly or enqueues its execution to thread pool thread.
|
protected |
Referenced by log4cplus::DeviceAppender< Device >::append().
|
virtual |
Return the currently set ErrorHandler for this Appender.
log4cplus::spi::FilterPtr log4cplus::Appender::getFilter | ( | ) | const |
Get the filter chain on this Appender.
|
virtual |
Returns the layout of this appender.
The value may be NULL.
This class owns the returned pointer.
|
virtual |
Get the name of this appender.
The name uniquely identifies the appender.
|
inline |
Returns this appenders threshold LogLevel.
See the {} method for the meaning of this option.
Definition at line 255 of file appender.h.
|
inline |
Check whether the message LogLevel is below the appender's threshold.
If there is no threshold set, then the return value is always true
.
Definition at line 272 of file appender.h.
References log4cplus::NOT_SET_LOG_LEVEL.
bool log4cplus::Appender::isClosed | ( | ) | const |
Check if this appender is in closed state.
|
virtual |
Set the ErrorHandler for this Appender.
void log4cplus::Appender::setFilter | ( | log4cplus::spi::FilterPtr | f | ) |
Set the filter chain on this Appender.
|
virtual |
Set the layout for this appender.
Note that some appenders have their own (fixed) layouts or do not use one. For example, the SocketAppender ignores the layout set here.
|
virtual |
Set the name of this appender.
The name is used by other components to identify this appender.
|
inline |
Set the threshold LogLevel.
All log events with lower LogLevel than the threshold LogLevel are ignored by the appender.
In configuration files this option is specified by setting the value of the Threshold option to a LogLevel string, such as "DEBUG", "INFO" and so on.
Definition at line 265 of file appender.h.
void log4cplus::Appender::syncDoAppend | ( | const log4cplus::spi::InternalLoggingEvent & | event | ) |
This method performs threshold checks and invokes filters before delegating actual logging to the subclasses specific {} method.
void log4cplus::Appender::waitToFinishAsyncLogging | ( | ) |
This method waits for all events that are being asynchronously logged to finish.
|
protected |
Asynchronous append.
Definition at line 319 of file appender.h.
|
protected |
Is this appender closed?
Definition at line 327 of file appender.h.
|
protected |
It is assumed and enforced that errorHandler is never null.
Definition at line 309 of file appender.h.
|
protected |
The first filter in the filter chain.
Set to null
initially.
Definition at line 306 of file appender.h.
|
protected |
Definition at line 321 of file appender.h.
|
protected |
Definition at line 323 of file appender.h.
|
protected |
Definition at line 322 of file appender.h.
|
protected |
The layout variable does not need to be set if the appender implementation has its own layout.
Definition at line 296 of file appender.h.
|
protected |
Optional system wide synchronization lock.
Definition at line 312 of file appender.h.
|
protected |
Appenders are named.
Definition at line 299 of file appender.h.
|
protected |
|
protected |
Use lock file for inter-process synchronization of access to log file.
Definition at line 316 of file appender.h.