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:

cat.debug(myObject.showState());

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?

dwh


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
matter.

James Stauffer






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



Reply via email to