On Friday 30 November 2001 01:49 pm, you wrote:
> > I think this can be an appropriate timing to start cleaning up the
> > logging code. We have to find a policy and stick to it: I tend to say
> > that we should *always* do a isDebugEnabled() or a isInfoEnabled()
> > before spitting out Strings. I'm not that sure that such a policy should
> > be enforced for levels of warn and above.
>
> I totally agree.
> This sped up my app quite a bit.
> Maybe a static utility method that does the check is nicers than many ifs.

Assuming you are talking about something like:

public static logDebug(final Logger logger, final String string) {
 if (logger.isDebugEnabled()) {
        logger.debug(string);
  }
}

that won't work because the point is to never reach the code that constructs 
the string. AFAIK it has to be done as
 if (getLogger().isDebugEnabled()) getLogger().debug("your message");

I followed Stefano's rant on this a month ago or so and have been changing 
all my code to the above syntax.

<ide plug>
Using a nifty IDE such as IDEA from IntelliJ, you can define templates in 
code, so i just type debug<tab> and it spits out 
if (getLogger().isDebugEnabled()) getLogger().debug();
with the cursor inbetween the debug() braces ready for the string. Makes it 
dead-easy.
</ide plug>

-pete

-- 
peter royal -> [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to