On Mar 25, 2009, at 11:49 PM, Mario Ivankovits wrote:
if (log.isDebugEnabled())
{
log.debug("putFile: " + file.getName());
}
with
logger.entry(file.getName());
This is not the same, in the second example getName() gets evaluated
every time, regardless of the configured log-level. Depending on how
complicated it is to collect the message, this might become a
performance problem. the if (log.isXXXEnabled()) prevents that.
I'd prefer to keep it the way it is.
a) As I said in my original response, although I prefer SLF4J I
wouldn't switch from commons-logging without a lot of discussion.
There isn't a good reason to do it at this point.
b) You are correct that file.getName() gets evaluated every time.
Usually the call to getName() should be extremely cheap and will
actually be inconsequential to the time it takes to check whether
logging is enabled. If it was routinely doing some expensive String
construction then, yes it should be wrapped in if
(logger.isTraceEnabled()).
Ralph
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org