[slf4j-dev] Why no error(Throwable) on the Logger interface?

Joern Huxhorn jhuxhorn at googlemail.com
Wed May 27 10:17:46 CEST 2009


Jukka Zitting wrote:
> Hi,
>
> On Wed, May 27, 2009 at 9:36 AM, Robert Elliot <rob at lidalia.org.uk> wrote:
>   
>> Just curious about this - I often find myself catching an exception and not
>> really having anything to say about it other than that I want to log the
>> exception.
>>     
>
> I've found that there's always something useful you can (and should)
> say in such cases. Even if it's just: "Failed to do X", where "X" is
> the stuff inside the try block. Giving even minimal context to the
> exception is *really* useful in many cases, especially since many
> logging configurations out there don't include stack traces or line
> numbers in the log output...
>
> So IMHO having the logging API force you to say at least something
> beyond the exception you got is a Really Good Thing (TM).
>
> BR,
>
> Jukka Zitting
>   
I agree 100%. Having only the methods as they are now kind of enforces a
better overall logging style.

While one still has the option to simply call logger.error("",ex) it
should seriously make you feel a bit guilty, especially in non-trivial,
larger projects... I'd also point at it in a code-review, asking "wtf?" ;)

Regards,
Joern.



More information about the slf4j-dev mailing list