<div dir="ltr">Hello Ceki,<br><br>Many thanks for your previous message.<br><br>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. <br>
<br>Now I have the same kind of issue with a DBAppender. <br>I need to be sure that the data persisted in my database after a call to log.error(myErrorObject)...<br>If it is not the case, the following actions must be skipped and the database administrator needs to be notified that a problem occured.<br>
<br>Polling StatusManager for errors Status is not very efficient.<br>As you suggested, adding listeners to the StatusManager and implementing an alernate StatusManager seems to be the best solutions.<br><br>Do you any estimation when these features will be available in logback ?<br>
<br>Thank you.<br>Kind regards.<br><br>Jonathan Dray<br><br><br><div class="gmail_quote">2008/7/22 Ceki Gulcu &lt;listid@qos.ch&gt;:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello Jonathan,<br>
<br>
Logback uses a slightly different approach for dealing with internal errors. It<br>
uses a StatusManager. Each appender is attached to a logger but also to a<br>
LoggerContext. In turn, the LoggerContext has a reference to a StatusManager.<br>
All this would be meaningless if logback components did not make use of the<br>
StatusManger. If you look in the code, logback components, including<br>
JMSQueueAppener, add a status message when they run into an error.<br>
<br>
You would need to listen to these status messages and as soon as you receive one<br>
which indicating errors in your JMSQueueAppender, you would switch to a<br>
different JMS destination.<br>
<br>
How could you set a listener for status messages? You could either create your<br>
own StatusManager class and set it for the LoggerContext, or alternatively, you<br>
could add a listener to the existing StatusManager. Unfortunately, at this time,<br>
StatusManager cannot be changed, nor does StatusManager class accept listeners.<br>
However, you can expect these limitations to be lifter soon. See also [1, 2].<br>
<br>
Does this help?<br>
<br>
[1] <a href="http://jira.qos.ch/browse/LBCLASSIC-59" target="_blank">http://jira.qos.ch/browse/LBCLASSIC-59</a><br>
[2] <a href="http://tinyurl.com/658jgk" target="_blank">http://tinyurl.com/658jgk</a><br>
<div><div></div><div class="Wj3C7c"><br>
<br>
<br>
Jonathan Dray wrote:<br>
&gt; Hi,<br>
&gt;<br>
&gt; I previously used log4j with a JMSAppender sending messages to a specific<br>
&gt; ActiveMq Queue.<br>
&gt; I managed to configure a FallBackErrorHandlor with a second JMSAppender in<br>
&gt; case the first JMSAppender was not able to write to the queue.<br>
&gt; The ErrorHandler was also configured to send emails when something went<br>
&gt; wrong.<br>
&gt;<br>
&gt; I now want to try logback and wonder if there is a way to get errors<br>
&gt; returned by loggers at runtime.<br>
&gt; Plesae consider the following situation :<br>
&gt;<br>
&gt; **<br>
&gt; &nbsp;* Hello world!<br>
&gt; &nbsp;*<br>
&gt; &nbsp;*/<br>
&gt; public class App<br>
&gt; {<br>
&gt; &nbsp; &nbsp; public static void main( String[] args )<br>
&gt; &nbsp; &nbsp; {<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ...<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ... (some code herer)<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Logger log = LoggerFactory.getLogger(&quot;myLogger&quot;);<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; log.debug(&quot;App : main&quot;);<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; System.out.println( &quot;Normal end of my process&quot; );<br>
&gt; &nbsp; &nbsp; }<br>
&gt; }<br>
&gt;<br>
&gt; Let&#39;s assume the &quot;myLogger&quot; is configured to use a JMSAppender.<br>
&gt; I want to know if the log.debug call failed and then not to display &quot;Normal<br>
&gt; end of my process.&quot;<br>
&gt;<br>
&gt; 1. Is this possible ?<br>
&gt; 2. How should I handle errors dealing with logback logger ?<br>
&gt;<br>
&gt; Thank you<br>
&gt; Regards,<br>
&gt;<br>
&gt; Jonathan Dray<br>
&gt;<br>
&gt;<br>
&gt;<br>
</div></div>&gt; ------------------------------------------------------------------------<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Logback-user mailing list<br>
&gt; Logback-user@qos.ch<br>
&gt; <a href="http://qos.ch/mailman/listinfo/logback-user" target="_blank">http://qos.ch/mailman/listinfo/logback-user</a><br>
<br>
--<br>
Ceki Gülcü<br>
<br>
QOS.ch is looking to hire talented developers located in Switzerland<br>
to work on cutting-edge software projects. If you think you are<br>
qualified, then please contact ceki@qos.ch.<br>
_______________________________________________<br>
Logback-user mailing list<br>
Logback-user@qos.ch<br>
<a href="http://qos.ch/mailman/listinfo/logback-user" target="_blank">http://qos.ch/mailman/listinfo/logback-user</a><br>
</blockquote></div><br></div>