Package org.apache.log4j.varia
Class FallbackErrorHandler
- java.lang.Object
-
- org.apache.log4j.varia.FallbackErrorHandler
-
- All Implemented Interfaces:
ErrorHandler
,OptionHandler
public class FallbackErrorHandler extends java.lang.Object implements ErrorHandler
TheFallbackErrorHandler
implements the ErrorHandler interface such that a secondary appender may be specified. This secondary appender takes over if the primary appender fails for whatever reason.The error message is printed on
System.err
, and logged in the new secondary appender.- Author:
- Ceki Gücü
-
-
Constructor Summary
Constructors Constructor Description FallbackErrorHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activateOptions()
No options to activate.void
error(java.lang.String message)
Print a the error message passed as parameter onSystem.err
.void
error(java.lang.String message, java.lang.Exception e, int errorCode)
Prints the message and the stack trace of the exception onSystem.err
.void
error(java.lang.String message, java.lang.Exception e, int errorCode, LoggingEvent event)
Prints the message and the stack trace of the exception onSystem.err
.void
setAppender(Appender primary)
The appender to which this error handler is attached.void
setBackupAppender(Appender backup)
Set the backup appender.void
setLogger(Logger logger)
Adds the logger passed as parameter to the list of loggers that we need to search for in case of appender failure.
-
-
-
Method Detail
-
setLogger
public void setLogger(Logger logger)
Adds the logger passed as parameter to the list of loggers that we need to search for in case of appender failure.- Specified by:
setLogger
in interfaceErrorHandler
- Parameters:
logger
- One of the loggers that will be searched for the failing appender in view of replacement.
-
activateOptions
public void activateOptions()
No options to activate.- Specified by:
activateOptions
in interfaceOptionHandler
-
error
public void error(java.lang.String message, java.lang.Exception e, int errorCode)
Prints the message and the stack trace of the exception onSystem.err
.- Specified by:
error
in interfaceErrorHandler
-
error
public void error(java.lang.String message, java.lang.Exception e, int errorCode, LoggingEvent event)
Prints the message and the stack trace of the exception onSystem.err
.- Specified by:
error
in interfaceErrorHandler
- Parameters:
message
- The message assoicated with the error.e
- The Exption that was thrown when the error occured.errorCode
- The error code associated with the error.event
- The logging event that the failing appender is asked to log.
-
error
public void error(java.lang.String message)
Print a the error message passed as parameter onSystem.err
.- Specified by:
error
in interfaceErrorHandler
-
setAppender
public void setAppender(Appender primary)
The appender to which this error handler is attached.- Specified by:
setAppender
in interfaceErrorHandler
-
setBackupAppender
public void setBackupAppender(Appender backup)
Set the backup appender.- Specified by:
setBackupAppender
in interfaceErrorHandler
-
-