[slf4j-user] Varargs for Logger methods

Ceki Gülcü listid at qos.ch
Wed Feb 22 21:52:01 CET 2006


At 04:54 PM 2/22/2006, Kostis Anagnostopoulos wrote:

[snip]
 > In a relatively futuristic scenario where your custom event handling rules
> > required you to combine the exception and the parameters in a single event,
> > you could write:
> >
> > logger.error(MyMarkers.EXCETION_AS_PARAM,
> >              "While fiddling with nose using {} got an exception {}",
> >              myIndex,
> >              etiquetteExcetion);
> >
> > A logging system with marker support could take notice of the
> > EXCETION_AS_PARAM marker to print the stack trace for "etiquetteExcetion".
>
>But at the above form it is not obvious whether to include the stack
>trace or not.

No, it is not obvious but so are the requirements (not obvious). The task 
is to print a log statement with parameters as well as an exception in a 
single statement. The above workaround is a little convoluted but hopefully 
fulfills the requirements.

>It would be much better to have the Throwable as the before the msg
>and not requiring the '{}' to exists in the message!
>
>-------
>
>Any way, are you absolutely definitive that there can't be, at this
>stage, any modification to the API as i proposed (swaping the
>Throwable argument BEFORE the msg string agg) ?

To be honest with you, I don't think there is any chance of swapping 
Throwable argument before the msg argument. For a logging system, it is 
rather important to get the signatures in Logger interface right. SLF4J 
offers two additions, Markers and parameterized messages. Otherwise, 
SLF4J's Logger interface is not very different from that of log4j or JCL, 
whereas placing the throwable first may be considered too radical a change. 
As mentioned in a previous mail, logging exceptions and parameterized 
messages are supported separately but not simultaneously.

>Tnakh you for yor answers all this time,

My pleasure even if I would have liked to give you a more amenable answer.

>     ankostis

-- 
Ceki Gülcü




More information about the slf4j-user mailing list