directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ceki Gülcü <>
Subject Re: Logging and Logger Name Conventions
Date Mon, 14 Nov 2005 10:11:23 GMT
At 06:46 PM 11/12/2005, Alex Karasulu wrote:

>>2.  I spotted a few calls to which are not wrapped in
>>log.isxxxEnabled() calls.  This can lead to inefficiencies especially when
>>the call involves String concatenation.  See
>>org.apache.ldap.server.jndi.ServerContextFactory 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

I hope this helps,


Ceki Gülcü

   The complete log4j manual:
   Improve your Sudoku skills at

View raw message