[slf4j-dev] Why no error(Throwable) on the Logger interface?
Jukka Zitting
jukka.zitting at gmail.com
Thu May 28 17:37:44 CEST 2009
Hi,
On Thu, May 28, 2009 at 4:32 PM, Robert Elliot <rob at lidalia.org.uk> wrote:
> I take it you include a date stamp in all your log messages then?
Point taken. Though in fact I would put a timestamp in a log message
if it was directly relevant to the logged event ("System time updated
to {}", time). And I've seen plenty of logs out there without thread
names in them.
Anyway, what I was trying to say is that you can typically get away
with less detailed log messages when you have access to the source
code (and understand it, e.g. you known how the controller in your
example it works) and detailed logging metadata (thread names, line
numbers, stack trackes, etc.). But in cases where this is not true
(and given the purpose of SLF4J, I'd argue that this applies to the
majority of SLF4J deployments), a clear log message is often extremely
useful.
For example, if I'm using a third party library that manages threads
and uses SLF4J for logging, how am I going to tell the difference
between an uncaught exception from a managed thread and some other
unexpected error in the thread manager if the only thing I'm seeing is
the exception? The former option indicates a problem in a managed
thread, and the latter in the thread manager. I could perhaps deduce
the difference by inspecting the stack trace (if available), but that
requires quite a bit more effort than simply reading the log message.
So, while adding the proposed signature doesn't directly hurt me (I
can still keep using the more detailed options), I'm worried that
having a signature like that encourages coding habits that will
decrease the overall benefits of logs.
BR,
Jukka Zitting
More information about the slf4j-dev
mailing list