[slf4j-user] Use of message format strings w/ throwables

Joern Huxhorn jhuxhorn at googlemail.com
Wed Jun 24 21:15:07 CEST 2009


Absolutely no need to apologize, I just wanted to point you to the  
tickets on the topic - including the ongoing discussion.

I was in a bit of a hurry (on the way to work) so my answer was a  
little short ;)

Those topics reappear every few weeks and I really think that this  
should be added to SLF4J.

While ticket 70 can (and should) be fixed without implementing ticket  
31, both should be addressed at some point.

Regards,
Joern.

On 24.06.2009, at 08:45, Chad La Joie <chad.lajoie at switch.ch> wrote:

> Sorry, I missed #70 when looking through the bug DB.  I did see #31  
> but the use of varargs isn't what I was after.
>
> Joern Huxhorn wrote:
>> +1 from me, the relevant bugs are
>> http://bugzilla.slf4j.org/show_bug.cgi?id=70
>> and
>> http://bugzilla.slf4j.org/show_bug.cgi?id=31
>> Regards,
>> Joern.
>> On 24.06.2009, at 07:41, Chad La Joie wrote:
>>> The current API does not let you use the message formatting  
>>> functionality  in conjunction with Throwable arguments.  I've seen  
>>> discussion that the reason for this is that if you're dealing with  
>>> an exception the overhead is already so high that the performance  
>>> benefit of using the format string to defer final message  
>>> constructions is meaningless.
>>>
>>> However, I'd like to propose that readability might be another  
>>> reason for allowing this.  Take for example this message:
>>>
>>> log.error("Some bad thing happened because request with ID '" + id  
>>> + "' from requester '" + requesterId + "' did not meet security  
>>> requirement '" + secPolId + "'", e)
>>>
>>> I would argue that the following is much more readable:
>>>
>>> log.error("Some bad thing happened because request with ID '{}'  
>>> from requester '{}' did not meet security requirement '{}'", new  
>>> Object[] {id, requesterId, secPolId}, e)
>>>
>>> This would require adding a new method for each log level with the  
>>> arguments; format, argArray, throwable.
>>>
>>> Does this seem like a reasonable addition to the API strictly from  
>>> a readability aspect within the code using SLF4J?
>>>
>>> -- 
>>> SWITCH
>>> Serving Swiss Universities
>>> --------------------------
>>> Chad La Joie, Software Engineer, Net Services
>>> Werdstrasse 2, P.O. Box, 8021 Zürich, Switzerland
>>> phone +41 44 268 15 75, fax +41 44 268 15 68
>>> chad.lajoie at switch.ch, http://www.switch.ch
>>>
>>> _______________________________________________
>>> user mailing list
>>> user at slf4j.org
>>> http://www.slf4j.org/mailman/listinfo/user
>> _______________________________________________
>> user mailing list
>> user at slf4j.org
>> http://www.slf4j.org/mailman/listinfo/user
>
> -- 
> SWITCH
> Serving Swiss Universities
> --------------------------
> Chad La Joie, Software Engineer, Net Services
> Werdstrasse 2, P.O. Box, 8021 Zürich, Switzerland
> phone +41 44 268 15 75, fax +41 44 268 15 68
> chad.lajoie at switch.ch, http://www.switch.ch
>
> _______________________________________________
> user mailing list
> user at slf4j.org
> http://www.slf4j.org/mailman/listinfo/user



More information about the slf4j-user mailing list