Hi
I had a query about logging. Currently, we use jdk 1.4 and use log4j 1.2.8 for logging. The code goes something like this -
logger.log(LOGLEVEL_DEBUG, METHOD_NAME, "Hello World");
Now, this statement gets executed even if the LOGLEVEL is set to something higher than DEBUG (ERROR in our application). The only thing is that the log is not wriiten to the output. We've got zillions of such statements in our code and I was wondering if this could be a significant performance bottleneck.
The most obvious solution seems to be do something like this -
if (logger.isDebugLoggingEnabled())
{
logger.log(LOGLEVEL_DEBUG, METHOD_NAME, "Hello World");
}
My question is, which is the more expensive operation? Ideally, the loggger.log() method must be checking the logger level somewhere and therefore the if() approach should be better.
Thoughts, comments???
Thanks,
Rajiv