logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Heaberlin" <heabd...@yahoo.com>
Subject RE: Fallback Error Handler behavior
Date Tue, 17 Jun 2003 22:56:39 GMT
No, we encountered similar behavior (losing the event that *caused* the
primary appender to call errorHandler.error(...)) and looked at the
source for the FallbackErrorHandler.

Our solution was to create a new error handler class called
FailoverErrorHandler which never replaces the primary Appender. In the
event of its primary Appender calling any signature of error(...), our
custom error handler class simply wrote to standard out and sent the
LoggingEvent to the backup appender.  (We did add some other custom code
to our new error handler that would report errors by other means as
well, typically by using a named Logger instance... but that's another
story).

In short, the current FallbackErrorHandler implementation simply
"switches" Appenders for the Logger whenever *some* but not all of the
ErrorHandler::error(...) methods are called.  For "failover" behavior
you'll have to implement your own custom ErrorHandler (it's not that
difficult though - one of my favorite aspects of Log4J is its design -
the simplicity of implementing/extending the Interfaces and base classes
to achieve exactly the functionality your enterprise requires.

Hope this helps,


-Scott Heaberlin
 

> -----Original Message-----
> From: Buchanan, Paul [mailto:Paul.Buchanan@thomson.com] 
> Sent: Tuesday, June 17, 2003 1:46 PM
> To: 'log4j-user@jakarta.apache.org'
> Subject: Fallback Error Handler behavior
> 
> 
> I have a few questions regarding the FallbackErrorHandler's 
> behavior.  I have a FallbackErrorHandler attached to an 
> appender that writes to a SQL database.  From my testing, it 
> looks like upon the first error writing to the database, the 
> FallbackErrorHandler adds the secondary appender to the 
> logger, and the event is not logged.  Log events after this 
> are then logged to both the primary and secondary appenders 
> regardless of the existence of an error.  Upon another error, 
> the event is correctly logged to the secondary appender.
> 
> It was my understanding that each and every event would be 
> logged, and that the secondary appender would only be logged 
> to in event of an error.  This is not the behavior that I am 
> experiencing.  Should I be getting different behavior?
> 
> Thanks,
> 
> Paul Buchanan
> email: paul.buchanan@thomson.com
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-user-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: log4j-user-help@jakarta.apache.org


Mime
View raw message