[logback-user] Throwable with Java 1.6 Style?

Thorbjørn Ravn Andersen thunderaxiom at gmail.com
Sat Sep 13 00:48:08 CEST 2008

Ceki Gulcu skrev  den 12-09-2008 20:47:
> Eric Faden wrote:
>> Why is there no way to do something like...
>> logger.error("blah blah {} blah", exception, object);
>> It seems that the only way to pass that in to the logger is to use
>> if (logger.isErrorEnabled()) logger.error("blah blah " + 
>> object.toString() + " blah", e);
>> or am I mistaken?  It seems that this would be a useful function to make 
>> available.
> No, you are right. Blame the SLF4J API. Those morons!
I think I'd better elaborate a bit on Ceki's rather brief explanation :)

It is notoriously hard to evolutionarily improve an API and get it 
exactly right at all the intermediate steps.

The question is how this _could_ be implemented at all without starting 
looking at the individual objects in a varargs and do stuff depending on 
their type (essentially putting the method selection in javac based on 
method signature inside slf4j instead), as there is the vararg putting 
stuff in a Object array (and exceptions  are objects).

If then the last argument is an exception THEN it should be interpreted 
traditionally with a stacktrace, but then you cannot stuff it in a 
placeholder (to get the string representation in the message).

What this means is basically that the current syntax breaks down, and 
perhaps that another approach is appropriate.  Feel free to open a JIRA 
issue if you feel this is important enough.

Best Regards,


More information about the Logback-user mailing list