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.laj...@switch.ch, http://www.switch.ch

_______________________________________________
user mailing list
user@slf4j.org
http://www.slf4j.org/mailman/listinfo/user

Reply via email to