On Mar 20, 2008, at 9:59 AM, Tim Watts wrote:
I suppose java.text.MessageFormat would do. For example:
log.debug(MessageFormat.format("Something happened; the context is
[{1}]",
myContextObj));
Although frankly, the simpler approach is something like this:
if (log.isDebugEnabled()) {
log.debug("Something happened; the context is [" +myContextObj
+"]");
}
The isDebugEnabled() call is an optimization technique. It allows
the program
to skip the string construction if the log isn't going to write debug
messages anyway.
If you want to use MessageFormat, use LogMF in the extras companion (http://logging.apache.org/log4j/extras
), like:
LogMF.debug(log, "Something happened: the context is [{0}]" ,
myContextObj);
LogMF is highly optimized to minimize the overhead of using
MessageFormat, particularly for simple cases this.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]