<div dir="ltr">Ceki:<br>Thanks for your reply. You got the point. After change the output statement to e.printStackTrace() the problem still there, it is not about slf4j or logback. <br>The JDK version I using is 1.6.0_7<br>
<br>Maybe this is a bug of JDK or this is some kind of optimization. If it is a optimization, do someone knows how to turn it off ?<br><br><br><div class="gmail_quote">On Tue, Sep 23, 2008 at 5:08 AM, Ceki Gulcu <span dir="ltr">&lt;listid@qos.ch&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hello Jarod,<br>
<br>
Which JDK are you using? On JDK 1.5.0, I see<br>
<div class="Ih2E3d"><br>
java.lang.ClassCastException: java.lang.String<br>
<br>
<br>
</div>What happens when you change the while loop to<br>
<div class="Ih2E3d"><br>
 &nbsp;while (true) {<br>
 &nbsp; &nbsp;try {<br>
 &nbsp; &nbsp; &nbsp;Integer a = (Integer) m.get(&quot;a&quot;);<br>
 &nbsp; &nbsp;} catch (Exception e) {<br>
</div> &nbsp; &nbsp; &nbsp;e.printStackTrace();<br>
<div><div></div><div class="Wj3C7c"> &nbsp; &nbsp;}<br>
 &nbsp;}<br>
<br>
<br>
Jarod Liu wrote:<br>
&gt; Hi all,<br>
&gt; I use slf4j(1.5.2) + logback(0.9.9) to do logging in my applications. I<br>
&gt; enouter a problem, while the load of logging going up, slf4j/logback<br>
&gt; well lost stack trace of a exception. &nbsp;Below is my test program and the<br>
&gt; test output<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; correct output:<br>
&gt; ----------------------------------------<br>
&gt; 11:33:38 ERROR [main]log.Logback.main -<br>
&gt; java.lang.ClassCastException: java.lang.String cannot be cast to<br>
&gt; java.lang.Integer<br>
&gt; &nbsp; &nbsp; at log.Logback.main(Logback.java:31)<br>
&gt;<br>
&gt; after some time, output turns to as below:<br>
&gt; --------------------------------------<br>
&gt; 11:44:18 ERROR [main]log.Logback.main -<br>
&gt; java.lang.ClassCastException<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; test program:<br>
&gt;<br>
&gt; public class Logback {<br>
&gt;<br>
&gt; &nbsp; &nbsp; private static Logger logger = LoggerFactory.getLogger(Logback.class);<br>
&gt;<br>
&gt;<br>
&gt; &nbsp; &nbsp; public static void main(String[] args) {<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; Map m = new HashMap();<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; m.put(&quot;a&quot;, &quot;dsfd&quot;);<br>
&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; while (true) {<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try {<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Integer a = (Integer) m.get(&quot;a&quot;);<br>
&gt;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } catch (Exception e) {<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; logger.error(&quot;&quot;, e);<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; }<br>
&gt; &nbsp; &nbsp; }<br>
&gt; }<br>
&gt;<br>
&gt;<br>
</div></div>&gt; ------------------------------------------------------------------------<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; user mailing list<br>
&gt; <a href="mailto:user@slf4j.org">user@slf4j.org</a><br>
&gt; <a href="http://www.slf4j.org/mailman/listinfo/user" target="_blank">http://www.slf4j.org/mailman/listinfo/user</a><br>
<font color="#888888"><br>
--<br>
Ceki Gülcü<br>
Logback: The reliable, generic, fast and flexible logging framework for Java.<br>
<a href="http://logback.qos.ch" target="_blank">http://logback.qos.ch</a><br>
_______________________________________________<br>
user mailing list<br>
<a href="mailto:user@slf4j.org">user@slf4j.org</a><br>
<a href="http://www.slf4j.org/mailman/listinfo/user" target="_blank">http://www.slf4j.org/mailman/listinfo/user</a><br>
</font></blockquote></div><br></div>