Jeremy Haile wrote:
I argued against writing our own wrappers in the past, but we have created some wrappers on another project that I feel are beneficial. Since we're discussing going through the code and replacing all of our log calls, I thought I'd mention it here.

Our wrapper takes in var-args and internally uses the MessageFormat class to substitute in arguments. This removes the problem when logging of string concatenation being slow since the string concatenation only takes place if the log level is set.

So code that used to look like this:
if( log.isDebugEnabled() ) {
log.debug( "User with ID [" + userId + "] logged into realm [" + realm + "]" );
}

can now look like:
log.debug( "User with ID {0} logged into realm {1}", userId, realm);
Do you know that you can do the exact same thing with slf4j, except that it does not use varargs, but allow you to use up to 3 objects ?

So you have the best of two worlds ...

--
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org


Reply via email to