I wasn't suggesting to change the logger classes but more like a wrapper....that will make the check and call the logger classes. This will allow me to have a little cleaner application code. Daniel Serodio <[EMAIL PROTECTED]> wrote:Calling isDebugEnabled() will avoid the cost of calculating ``"Entry number: " + i + " is " + String.valueOf(entry[i])''. There's no other way of avoiding this cost, because if you make this check inside logger, the JVM will create this concatenated String, pass this to the logger, which will then throw it away. But it will have been created already.
Also, you will tipically only check isDebugEnabled(), but not isInfoEnabled(), etc. Use it only when you're concatenating many strings, or calling (directly or indirectly) an expensive toString() method. Hope this helps, Daniel Serodio On Tue, 2003-02-11 at 15:26, Ashish Jain wrote: > All, > > I am looking at the log4j documentation and it states the following > > "To avoid the parameter construction cost write: > > if(logger.isDebugEnabled() { > logger.debug("Entry number: " + i + " is " + String.valueOf(entry[i])); > }" > > I do want to avoid the parameter construction cost, but I don't want to check for >IsXXXEnabled everytime I use a log statement because it makes my code clumsy. Is >there a better way of doing this ? Is there a config flag somewhere ? or should I >extend the logger classes and check for IsXXXenabled before calling the Log4j >classes. And then my code can call my log4jextended classes. Again, I don't want to >check for IsXXXEnabled every time I use a log statement. > > Any help is appreciated. > > Thks, > > - Ashish. > > > > --------------------------------- > Do you Yahoo!? > Yahoo! Shopping - Send Flowers for Valentine's Day -- Daniel Serodio CheckForte --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------- Do you Yahoo!? Yahoo! Shopping - Send Flowers for Valentine's Day