[slf4j-user] Java 5 version of SLF4J?

Joern Huxhorn jhuxhorn at bpinteractive.com
Thu Apr 24 17:11:43 CEST 2008


Christopher.White at bbh.com wrote:
> It's nice to see that you were on top of this already. 
> 
> My only issue with your fix is that it can be ambiguous as to which comes 
> first (params or exception). I'd much prefer putting the exception at the 
> front of the method signature (as was suggested by another user in either 
> this or the Logback mailing list)
> 
> i.e. error(Throwable t, String msg, Object params...)
> 
> This makes it much more clear where the exception should be placed. And, 
> like what was said by the other user, you could also optionally put the 
> exception into the message as a parameter without casting.

This would break compatibility with the current API which is a 
definitive no-no.

A Throwable as the last argument, however, will only be used as a 
Throwable instead of just a String if there are not enough {} parameters 
in the message. You could even have both if you add the Throwable twice.

I can also attest based, on experience, that people actually expect the 
exception as the last parameter.

What I mean with experience is that all the mistakenly added exceptions 
(which are silently swallowed at the moment if there's no {} left in the 
message string) in our company were mistakenly placed at that position, 
i.e. as the last argument.

I think this happened once or twice to *every* developer in our team...

Joern.




More information about the slf4j-user mailing list