commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Goers <>
Subject Re: [VFS] "anonymous" debug logging
Date Thu, 26 Mar 2009 07:12:32 GMT

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  


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message