[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
Sun Jan 27 17:05:51 CET 2008


http://bugzilla.slf4j.org/show_bug.cgi?id=70





------- Comment #1 from joern at huxhorn.de  2008-01-27 17:05 -------
Created an attachment (id=24)
 --> (http://bugzilla.slf4j.org/attachment.cgi?id=24&action=view)
A solution proposal.

I introduced a new method throwableAwareArrayFormat to replace the method
arrayFormat. This method returns a MessageFormat.Result containing both the
formatted message and, optionally, an exception.

The MessageFormat.Result.getThrowable() is only non-null if
- the last argument is of type Throwable and is not used while formatting the
message
- the last argument is of type Throwable and the messagePattern contains
invalid parameters. This is done so that the stack-trace is still available
even if the message contains an error. I thought this is ok because otherwise
you could probably miss an important exception because the pattern is wrong in
case of a very rare log statement...

This means that the Throwable is NOT returned if it's used in the message and
guarantees that no unexpected stack-traces will show up.

I deprecated arrayFormat so implementing projects can easily find the new
replacement method.
I also added test cases for the different scenarios.

This change should not produce any incompatibilities to prior versions because
superfluous arguments were previously just ignored.


-- 
Configure bugmail: http://bugzilla.slf4j.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the slf4j-dev mailing list