<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On 13.09.2008, at 12:59, Ceki Gulcu wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Thorbjørn Ravn Andersen wrote:<br><blockquote type="cite">Ceki Gulcu skrev &nbsp;den 12-09-2008 20:47:<br></blockquote><blockquote type="cite"><blockquote type="cite">Eric Faden wrote:<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">Why is there no way to do something like...<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">logger.error("blah blah {} blah", exception, object);<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">It seems that the only way to pass that in to the logger is to use<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">if (logger.isErrorEnabled()) logger.error("blah blah " + <br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">object.toString() + " blah", e);<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">or am I mistaken? &nbsp;It seems that this would be a useful function to make <br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite">available.<br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite">No, you are right. Blame the SLF4J API. Those morons!<br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><br></blockquote></blockquote><blockquote type="cite">I think I'd better elaborate a bit on Ceki's rather brief explanation :)<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">It is notoriously hard to evolutionarily improve an API and get it <br></blockquote><blockquote type="cite">exactly right at all the intermediate steps.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">The question is how this _could_ be implemented at all without starting <br></blockquote><blockquote type="cite">looking at the individual objects in a varargs and do stuff depending on <br></blockquote><blockquote type="cite">their type (essentially putting the method selection in javac based on <br></blockquote><blockquote type="cite">method signature inside slf4j instead), as there is the vararg putting <br></blockquote><blockquote type="cite">stuff in a Object array (and exceptions &nbsp;are objects).<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">If then the last argument is an exception THEN it should be interpreted <br></blockquote><blockquote type="cite">traditionally with a stacktrace, but then you cannot stuff it in a <br></blockquote><blockquote type="cite">placeholder (to get the string representation in the message).<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">What this means is basically that the current syntax breaks down, and <br></blockquote><blockquote type="cite">perhaps that another approach is appropriate. &nbsp;Feel free to open a JIRA <br></blockquote><blockquote type="cite">issue if you feel this is important enough.<br></blockquote><br>Pour your information, Joern Huxhorn has already filed a bug report on this topic<br> &nbsp;&nbsp;<a href="http://bugzilla.slf4j.org/show_bug.cgi?id=70">http://bugzilla.slf4j.org/show_bug.cgi?id=70</a><br><br><br>-- <br>Ceki Gülcü<br>Logback: The reliable, generic, fast and flexible logging framework for Java.<br><a href="http://logback.qos.ch">http://logback.qos.ch</a><br>_______________________________________________<br>Logback-user mailing list<br>Logback-user@qos.ch<br>http://qos.ch/mailman/listinfo/logback-user<br></div></blockquote><br></div><div>I've recently added that functionality to Lilith (&nbsp;<a href="http://lilith.huxhorn.de/">http://lilith.huxhorn.de/</a> ) in a pretty transparent way, i.e. the above code would have to look like this:<span class="Apple-style-span" style="color: rgb(84, 0, 0); "></span></div><div><span class="Apple-style-span" style="color: rgb(84, 0, 0); ">if (logger.isErrorEnabled()) logger.error("blah blah {}&nbsp;blah", object, e);</span></div><div><font class="Apple-style-span" color="#540000"><br></font></div><div><font class="Apple-style-span" color="#540000">The last argument is used as the Throwable *IF* it is not used up by a placeholder already.</font></div><div><font class="Apple-style-span" color="#540000">So&nbsp;if (logger.isErrorEnabled()) logger.error("blah blah {}&nbsp;blah {}", object, e); would not use e as the Throwable. If you'd like to use both the String representation and the Throwable you'd have to give it as an argument twice&nbsp;if (logger.isErrorEnabled()) logger.error("blah blah {}&nbsp;blah {}", object, e, e);</font></div><div><font class="Apple-style-span" color="#540000"><br></font></div><div><font class="Apple-style-span" color="#540000">Please keep in mind that e is simply ignored at the moment in case of</font></div><div><font class="Apple-style-span" color="#540000"><span class="Apple-style-span" style="color: rgb(0, 0, 0); "><div><span class="Apple-style-span" style="color: rgb(84, 0, 0); ">if (logger.isErrorEnabled()) logger.error("blah blah {}&nbsp;blah", object, e);</span></div><div><font class="Apple-style-span" color="#540000">so I think this is a pretty compatible enhancement.</font></div><div><font class="Apple-style-span" color="#540000"><br></font></div><div><font class="Apple-style-span" color="#540000">So if you use Lilith and you are using one of the Lilith appenders you'll get what you expect.</font></div><div><font class="Apple-style-span" color="#540000"><br></font></div><div><font class="Apple-style-span" color="#540000">Joern.</font></div></span></font></div><div><font class="Apple-style-span" color="#540000"><br></font></div></body></html>