[logback-user] Exception logging

Ceki Gulcu listid at qos.ch
Tue Nov 13 22:15:28 CET 2007


Parameterized logging is not available for exceptions. Given that exceptions by 
definition are rare, you don't need to optimize logging for them. You just write:

logger.error("Something went wrong because " + someReason, exception);

The difference in performance is measured in terms of microseconds which is 
usually not significant in case of exceptions.

Does the above make sense?

c_inconnu2 wrote:
> Hi,
> First, I was looking for a more recent log framework than log4j and I 
> just discovered logback : thanks for this great piece of software. I am 
> using it for a couple of hours now and I have a question about usage :
> With log4j i had :
> logger.error("Something went wrong because " + someReason, exception);
> But with logback (SLF4J) I have to keep this since the signature is :
> void org.slf4j.Logger.error(String msg, Throwable t)
> I would have thought that something like below had existed :
> void org.slf4j.Logger.error(String msg, Throwable t, Object[])
> so i would have written
> logger.error("Something went wrong because {}", exception, someReason);
> Any advice ? Thanks
> David
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://qos.ch/mailman/listinfo/logback-user

Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.

More information about the Logback-user mailing list