[slf4j-dev] [Bug 70] " logging a stack trace along with a parameterized string" solution proposal
bugzilla-daemon at pixie.qos.ch
bugzilla-daemon at pixie.qos.ch
Mon Sep 15 14:49:23 CEST 2008
http://bugzilla.slf4j.org/show_bug.cgi?id=70
--- Comment #12 from Thorbjørn Ravn Andersen <ravn at runjva.com> 2008-09-15 14:49:22 ---
(In reply to comment #11)
> I can only argue that *every* person (I think about seven already) that talked
> to me about this shortcoming of slf4j/logback was *always* assuming that the
> exception was the last of the given arguments.
This I would too (and I don't think I said otherwise above).
I thought it some more over, and it just dawned on me that my suggestion with
replacing varargs with explicit methods is source compatible but not binary
compatible (I would still like them, as you need to write new Object[] {a, b,
c....} already with more than two arguments, and varargs is just AFAIK syntatic
sugar on the Object[] argument).
> I even received some Lilith bug reports that guessed that it was a Lilith
> problem that the exceptions wouldn't show up. That's one of the reasons why I
> implemented a "fix" in my own appenders.
I think that the approach with simply defining the semantics of the arguments
leftover after the formatting is sound, and I suggest the following (which can
later be expanded):
==
"If there are more arguments supplied than placeholders in the message strings,
the following rules apply after the message string has been formatted:
* If and only if there is exactly one unused argument object AND "object
instanceof java.lang.Exception" is true, then the stack trace from the object
is logged with the formatted message
* All other situations are undefined
"
There should probably be a reference to the method used to log the stack trace
:)
> What would be the way to actually use the throwable.toString() in a
> parameterized logging message? Would you expect to manually use ""+throwable in
I understand that per default the String.valueOf(object) is used. I cannot
remember right now if and where user supplied toStringgers can be supplied.
This would apply to all parameters used for formatting.
I would strongly suggest to keep the rules simple - otherwise it WILL bite some
day :)
--
Configure bugmail: http://bugzilla.slf4j.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the slf4j-dev
mailing list