Whether it be java.util.logging, commons-logging, log4j, and even the most recent slf4j and logback, none of these APIs propose methods such as, say:
void debug(String format, Object... args);
where format
is a string parsed using Formatter
. Instead, they stick with MessageFormat
.
I understand that it would conflict with existing prototypes, so why not debugf()
or the like, but why aren't there any such methods given that Formatter
is as old as Java 1.5?
Is it for performance reasons, backwards compatibility... ?
(note, I am really talking about Formatter
, ie including placeholders such as %s
, %02x
etc)
slf4j does. See http://www.slf4j.org/apidocs/org/slf4j/Logger.html. It's one of the main advantages (to me) of slf4j over log4j. It avoids the need for isDebugEnabled()
everywhere.
EDIT :
The slf4j documentation explains why it doesn't use the standard formatting from the JDK:
SLF4J uses its own message formatting implementation which differs from that of the Java platform. This is justified by the fact that SLF4J's implementation performs about 10 times faster but at the cost of being non-standard and less flexible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With