logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Denis Haskin <De...@HaskinFerguson.net>
Subject Re: Which Way of "Extending" Gives Fastest Performance
Date Thu, 22 Apr 2004 15:54:28 GMT
This is a little off from the original question, and note that we also 
haven't touched any of our logging code in quite a while, but:

We found that we had to address some performance problems where there 
was an insignificant cost to creating the string that we were going to 
send to log4j.

For example, you might have:


or some such thing, and the issue is that even if debug logging is 
disabled, the call into cat.debug() is still made, which means the call 
to myObject.showState() is also made, even if the results from 
showState() are in fact never used.

We handled this by wrapping all of logging statements (well, at least 
debug ones, I think) in a conditional, like this:

   if (cat.isDebugEnabled()) cat.debug(myObject.showState());

to avoid that overhead.

I was never really happy with this.  I suppose some sort of helper 
object might have made more sense... or is there a better way now to 
deal with this?


James Stauffer wrote:

>Do you know that logging has a significant effect on your current
>performance?  If it only takes 0.01% of CPU time then it doesn't really
>James Stauffer

To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org

View raw message