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

Chad La Joie chad.lajoie at switch.ch
Wed Jun 24 08:45:38 CEST 2009


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




More information about the slf4j-user mailing list