Ceki Gülcü wrote:
At 04:23 PM 6/18/2003 +0200, you wrote:

Finally, there is the speed issue. As fast as an if.isDebugEnabled() may be, we have seen that some places need a logging statement in a "close loop", and this makes performance degrade.


How is that possible? If the logging statements are disabled, then they are not used. Otherwise, if they are enabled, then they generate massive output rendering the logs useless. So placing log statements in tight loops is always a lose-lose proposition, or?

Well, I can see the value of logging in tight loops at the DEBUG level. Even though you end up with a lot of log statements you might only be interested in the last one (the one that failed). Perhaps a little creative coding can alleviate the performance hit:

void doLoop()
{
    if (log.isDebugEnabled())
    {
        for (int i = 0; i < limit; i++)
        {
            log.debug("i = " + i);
            process(i);
        }
    }
    else
    {
        for (int i = 0; i < limit; i++)
        {
            process(i);
        }
    }
}

void process(int i)
{
   // loop interitor
}



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



Reply via email to