At 06:46 PM 11/12/2005, Alex Karasulu wrote:
>>2. I spotted a few calls to log.xxx() which are not wrapped in
>>log.isxxxEnabled() calls. This can lead to inefficiencies especially when
>>the log.xxx() call involves String concatenation. See
>>org.apache.ldap.server.jndi.ServerContextFactory log.info() calls for
>>examples. Can these be changed?
>>
>>
>Sure Simon you are 100% right. I don't think anyone has made it a good
>practice to wrap these things. I will make sure I do this all the
>time. I will accept and apply any patches that wrap log called with a
>conditional to see if the log level is enabled. I will apply it immediate
>if you or anyone else can provide them.
If you are using SLF4J, then wrapping is not necessary. Instead of writing,
if(logger.isDebugEnabled()) {
logger.debug("User name is "+name+".");
}
you can write
logger.debug("User name is {}.", name);
The second form is more convenient, has a smaller footprint (both in memory
and on disk) and is slightly faster.
For more details, please refer to http://www.slf4j.org/faq.html#2.3
I hope this helps,
>Thanks,
>Alex
--
Ceki Gülcü
The complete log4j manual: http://www.qos.ch/log4j/
Improve your Sudoku skills at http://www.sudoku-grok.com/
|