What is the point of having the if statement here? The severity level can be changed in log4j.xml config file. If the severity level is debug, it'll log the debug message, else it will not.
What is the significance of the if statement below?
if (log.isDebugEnabled())
{
log.debug("I am logging something");
}
In your example there is no need for an 'if' statement
But if you take the below example then you can see that we do a concatenation and if the log level is info then unneccesarily this concatenation operation will be done. For better performance we check this condition.
if (log.isDebugEnabled())
{
log.debug("I am logging " + 1234 + ".");
}
Extra info:
Use slf4j to avoid such if conditions. The above statement can be rewritten in slf4j as follows,
log.debug("I am logging {} .", 1234);