[logback-user] FallBack Appender and error handler

Jonathan Dray jonathan.dray at gmail.com
Thu Jul 24 18:30:30 CEST 2008


Hello Ceki,

Many thanks for your previous message.

Concerning the JMSAppender, I will implement a slightly modified version of
JMSQueueAppender with multiple destinations. If a destination is not
available then I will try to send the message to another one in the list. I
will also notify an administrator by mail in case of failure.

Now I have the same kind of issue with a DBAppender.
I need to be sure that the data persisted in my database after a call to
log.error(myErrorObject)...
If it is not the case, the following actions must be skipped and the
database administrator needs to be notified that a problem occured.

Polling StatusManager for errors Status is not very efficient.
As you suggested, adding listeners to the StatusManager and implementing an
alernate StatusManager seems to be the best solutions.

Do you any estimation when these features will be available in logback ?

Thank you.
Kind regards.

Jonathan Dray


2008/7/22 Ceki Gulcu <listid at qos.ch>:

> Hello Jonathan,
>
> Logback uses a slightly different approach for dealing with internal
> errors. It
> uses a StatusManager. Each appender is attached to a logger but also to a
> LoggerContext. In turn, the LoggerContext has a reference to a
> StatusManager.
> All this would be meaningless if logback components did not make use of the
> StatusManger. If you look in the code, logback components, including
> JMSQueueAppener, add a status message when they run into an error.
>
> You would need to listen to these status messages and as soon as you
> receive one
> which indicating errors in your JMSQueueAppender, you would switch to a
> different JMS destination.
>
> How could you set a listener for status messages? You could either create
> your
> own StatusManager class and set it for the LoggerContext, or alternatively,
> you
> could add a listener to the existing StatusManager. Unfortunately, at this
> time,
> StatusManager cannot be changed, nor does StatusManager class accept
> listeners.
> However, you can expect these limitations to be lifter soon. See also [1,
> 2].
>
> Does this help?
>
> [1] http://jira.qos.ch/browse/LBCLASSIC-59
> [2] http://tinyurl.com/658jgk
>
>
>
> Jonathan Dray wrote:
> > Hi,
> >
> > I previously used log4j with a JMSAppender sending messages to a specific
> > ActiveMq Queue.
> > I managed to configure a FallBackErrorHandlor with a second JMSAppender
> in
> > case the first JMSAppender was not able to write to the queue.
> > The ErrorHandler was also configured to send emails when something went
> > wrong.
> >
> > I now want to try logback and wonder if there is a way to get errors
> > returned by loggers at runtime.
> > Plesae consider the following situation :
> >
> > **
> >  * Hello world!
> >  *
> >  */
> > public class App
> > {
> >     public static void main( String[] args )
> >     {
> >             ...
> >             ... (some code herer)
> >             Logger log = LoggerFactory.getLogger("myLogger");
> >             log.debug("App : main");
> >             System.out.println( "Normal end of my process" );
> >     }
> > }
> >
> > Let's assume the "myLogger" is configured to use a JMSAppender.
> > I want to know if the log.debug call failed and then not to display
> "Normal
> > end of my process."
> >
> > 1. Is this possible ?
> > 2. How should I handle errors dealing with logback logger ?
> >
> > Thank you
> > Regards,
> >
> > Jonathan Dray
> >
> >
> >
> > ------------------------------------------------------------------------
> >
> > _______________________________________________
> > Logback-user mailing list
> > Logback-user at qos.ch
> > http://qos.ch/mailman/listinfo/logback-user
>
> --
> Ceki Gülcü
>
> QOS.ch is looking to hire talented developers located in Switzerland
> to work on cutting-edge software projects. If you think you are
> qualified, then please contact ceki at qos.ch.
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://qos.ch/mailman/listinfo/logback-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://qos.ch/pipermail/logback-user/attachments/20080724/b0017cba/attachment.htm 


More information about the Logback-user mailing list