Apache Log4cxx  Version 2.0.0
Loading...
Searching...
No Matches
log4cxx::spi::ErrorHandler Class Referenceabstract

Appenders may delegate their error handling to ErrorHandlers. More...

#include <errorhandler.h>

Inheritance diagram for log4cxx::spi::ErrorHandler:
log4cxx::spi::OptionHandler log4cxx::helpers::Object log4cxx::helpers::OnlyOnceErrorHandler log4cxx::varia::FallbackErrorHandler

Public Member Functions

virtual ~ErrorHandler ()
virtual void addAppenderHolder (const LogString &name, const AppenderAttachablePtr &clx)
 Override this to add clx to the list of collections to search for the failed appender.
virtual void setLogger (const LoggerPtr &logger)
 Override this to add a reference to a logger to which the failing appender might be attached.
virtual void error (const LogString &context, const std::exception &e, ErrorCode category=ErrorCode::GENERIC_FAILURE)=0
 This method is invoked when an exception is thown.
virtual void error (const LogString &message, ErrorCode category=ErrorCode::INVALID_CONFIGURATION)=0
 This method is invoked when an error is detected but an exception is not available (e.g.
virtual void error (const LogString &context, const std::exception &e, ErrorCode category, const LoggingEventPtr &event)
 This method is invoked when an exception is thown while processing a spi::LoggingEvent.
virtual void setAppender (const AppenderPtr &appender)
 Override this to set the appender holding this error handler.
virtual void setBackupAppender (const AppenderPtr &appender)
 Override this to set the appender to fallback upon in case of failure.
virtual bool errorReported () const
 Override this to report whether an error been raised to this reporter.
void activateOptions () override
 Activate the options that were previously set with calls to option setters.
void activateOptions (helpers::Pool &)
Public Member Functions inherited from log4cxx::spi::OptionHandler
virtual ~OptionHandler ()
void activateOptions (helpers::Pool &)
virtual void setOption (const LogString &option, const LogString &value)
 Override this method to set option to value.
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

Detailed Description

Appenders may delegate their error handling to ErrorHandlers.

Error handling is a particularly tedious to get right because by definition errors are hard to predict and to reproduce.

Please take the time to contact the author in case you discover that errors are not properly handled. You are most welcome to suggest new error handling policies or criticize existing policies.

Constructor & Destructor Documentation

◆ ~ErrorHandler()

virtual log4cxx::spi::ErrorHandler::~ErrorHandler ( )
inlinevirtual

Member Function Documentation

◆ activateOptions() [1/2]

void log4cxx::spi::ErrorHandler::activateOptions ( )
overridevirtual

Activate the options that were previously set with calls to option setters.

No action is performed in this implementation.

Implements log4cxx::spi::OptionHandler.

◆ activateOptions() [2/2]

Deprecated
This function is deprecated and will be removed in a future version.
Deprecated
Use activateOptions() without parameters instead

◆ addAppenderHolder()

virtual void log4cxx::spi::ErrorHandler::addAppenderHolder ( const LogString & name,
const AppenderAttachablePtr & clx )
virtual

Override this to add clx to the list of collections to search for the failed appender.

Parameters
namethe collection name.
clxhas a collection of appenders.

◆ error() [1/3]

virtual void log4cxx::spi::ErrorHandler::error ( const LogString & context,
const std::exception & e,
ErrorCode category,
const LoggingEventPtr & event )
virtual

This method is invoked when an exception is thown while processing a spi::LoggingEvent.

The default implementation discards event and calls the other error() overload.

Parameters
contextContextual information from where the exception is caught
eThe execption that was caught.
categoryThe category of error.
eventThe logging event that was not output

Reimplemented in log4cxx::varia::FallbackErrorHandler.

◆ error() [2/3]

virtual void log4cxx::spi::ErrorHandler::error ( const LogString & context,
const std::exception & e,
ErrorCode category = ErrorCode::GENERIC_FAILURE )
pure virtual

This method is invoked when an exception is thown.

Parameters
contextContextual information from where the exception is caught
eThe execption that was caught.
categoryThe category of error.

Implemented in log4cxx::helpers::OnlyOnceErrorHandler, and log4cxx::varia::FallbackErrorHandler.

◆ error() [3/3]

virtual void log4cxx::spi::ErrorHandler::error ( const LogString & message,
ErrorCode category = ErrorCode::INVALID_CONFIGURATION )
pure virtual

This method is invoked when an error is detected but an exception is not available (e.g.

Log4cxx is incorrectly configured).

Implemented in log4cxx::helpers::OnlyOnceErrorHandler, and log4cxx::varia::FallbackErrorHandler.

◆ errorReported()

virtual bool log4cxx::spi::ErrorHandler::errorReported ( ) const
virtual

Override this to report whether an error been raised to this reporter.

This implementation returns false always.

Reimplemented in log4cxx::helpers::OnlyOnceErrorHandler, and log4cxx::varia::FallbackErrorHandler.

◆ setAppender()

virtual void log4cxx::spi::ErrorHandler::setAppender ( const AppenderPtr & appender)
virtual

Override this to set the appender holding this error handler.

This method is called by a xml::DOMConfigurator file processor when the error handler is associated with an appender.

Reimplemented in log4cxx::varia::FallbackErrorHandler.

◆ setBackupAppender()

virtual void log4cxx::spi::ErrorHandler::setBackupAppender ( const AppenderPtr & appender)
virtual

Override this to set the appender to fallback upon in case of failure.

This method is called by the xml::DOMConfigurator file processor when the error handler is associated with an appender.

Reimplemented in log4cxx::varia::FallbackErrorHandler.

◆ setLogger()

virtual void log4cxx::spi::ErrorHandler::setLogger ( const LoggerPtr & logger)
virtual

Override this to add a reference to a logger to which the failing appender might be attached.

The failing appender can be searched and replaced only in the loggers you add through this method.

Parameters
loggerOne of the loggers that will be searched.

Reimplemented in log4cxx::varia::FallbackErrorHandler.


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