At 16:37 21.04.2001 -0700, you wrote:


>On Sat, 21 Apr 2001, Scott Sanders wrote:
>
>> What he meant was:
>> 
>>    if(log.isDebugEnabled())
>>      log.debug("Processing " + errorPage);
>> 
>> ;-)
>
>I can certainly see that, but it sure blows the "shorter code" advantage
>that was touted :-).  It also seems a little redundant -- if I want to
>make this message happen at the "warning" level instead, do I need to
>change two things?
>
>  if (log.isEnabledFor(Priority.WARN))
>    log.warn("Processing " + errorPage);

There is no Category.isWarnEnabled method for two reasons. 

1) Warning or error log statements are invoked much less frequently than debug of info 
statements.

2) Warning and error statements are usually enabled.

>Performance of this is not really relevant for things that happen once
>(context startup) or only rarely (unusual exceptions).  It matters a lot
>on stuff that happens for every single request.  And I would submit that
>"if (debug >= x)" will run faster that any method call to double check
>whether a logging level is enabled or not.

Undeniably, simplicity has its merits. 


>Moral of the story -- let's be very careful in how we instrument the code
>with logging calls.

Indeed. Ceki


Reply via email to