cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Donald <dona...@apache.org>
Subject Re: AW: log performance penalties
Date Tue, 10 Apr 2001 04:06:55 GMT
At 11:21  24/2/01 +0100, Stefano Mazzocchi wrote:
>> > I would suggest we start converting/implementing the logging in the way
>Stefano suggested.
>> > Either by
>> > 1. if (logger.debugIsActive()) logger.debug(...)
>>
>> +1
>>
>> > 2. if (LOG && logger.debugIsActive()) logger.debug(...)
>>
>> -1, because it over-complicates things, and I don't _really_ think it's
>> necessary. I assume logger.debugIsActive() is a fairly light weight
>> call, so we wouldn't be gaining too much.
>
>I tend to disagree: having a finely granular debugging infrastucture in
>place is *always* significant, no matter what evolution stage of the code
>you reach since you'll always have to modify stuff and break them.
>
>More than performance, I'm talking about size!
>
>Think about it: all the strings must be stored, this increases the class
>size.

Most compilers don't remove dead code as far as I am aware. The extra size
of a few strings is insignificant in the long run. Especially considering
that C2 is in active development. The ever so slight and largely
insignificant gain is offset by the increased comlexity of the system IMHO.
What is the saying .. premature optimisation is the root of all evil? ;)

>It's the best logging practice anyway since its as close to ASP you can get
>with Java today.
>
>I vote for something like
>
> if (Cocoon.LOG && logger.channelIsActive(Logger.DEBUG)) {
>   logger.debug("this " + is " pretty " + expensive);
> }

If Cocoon.LOG is a static final then theoretically it is dead code and can
be removed by compiler (but isn't in practical cases). If it is not a
static final then you could instead do something like the following (which
is already implemented in logkit).

At start of execution 

LogKit.setGlobalPriority( Priority.DEBUG );

then in your code

if (logger.isDebugEnabled()) {
  logger.debug("this " + is " pretty " + expensive);
}
Cheers,

Pete

*-----------------------------------------------------*
| "Faced with the choice between changing one's mind, |
| and proving that there is no need to do so - almost |
| everyone gets busy on the proof."                   |
|              - John Kenneth Galbraith               |
*-----------------------------------------------------*


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Mime
View raw message