[slf4j-dev] Why no error(Throwable) on the Logger interface?
Robert Elliot
rob at lidalia.org.uk
Wed May 27 09:36:35 CEST 2009
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
More information about the slf4j-dev
mailing list