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

Ceki Gulcu ceki at qos.ch
Wed May 27 15:19:18 CEST 2009


Hello Robert,

As Jukka's mail indicates, the modification you suggest is not
necessarily for the better. I personally tend to agree with
Jukka. There are probably others who would be more inclined to agree
with your position.  However, even in cases where we all agree on the
merits of a change, e.g. varargs [1], given that SLF4J is used by a
large number of components, we can't take the risk of making backward
incompatible changes. Even small *internal* changes have had important
repercussions in the past [2]. Changing major version numbers, would
not be of any help. If your project, say A, depends on library B which
uses SLF4J, and on library C which used SLF4J-2, assuming SLF4J and
SLF4J-2 are incompatible, you'd be stuck and probably reduced to
cursing SLF4J.

[1] http://bugzilla.slf4j.org/show_bug.cgi?id=31
[2] http://slf4j.org/faq.html#IllegalAccessError
[3] http://slf4j.org/faq.html#version_checks

Robert Elliot 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.  So I end up calling log.error(ex.getMessage(), ex) - 
> which seems a bit redundant as I'll get the message out anyway.
> 
> I understand why you couldn't do it in log4j, because there was already 
> an error(Object) and so you'd have confusion over whether they wanted to 
> log the exception including stack trace or just the exception's 
> toString.  But as that vagueness has been cleared up in SLF4J it would 
> be quite clear which method you were calling - error(Throwable) or 
> error(String).
> 
> Is it just too late to add it, since all SLF4J implementations would 
> need to be altered to implement it?  Ceki does effectively control 
> rather a lot of the SLF4J implementations (the JULI one, the Log4J one, 
> logback and slf4j-simple).  If it were added (say in a theoretical SLF4J 
> 2) then I presume that it would still be OK for the end user - a library 
> compiled against SLF4J 1.x would still work alongside libraries compiled 
> against SLF4J 2 and using an SLF4J 2 implementation.
> 
> Just a query.
> Rob

-- 
Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.
http://logback.qos.ch



More information about the slf4j-dev mailing list