I know this is old, but for anyone just finding this...
If you use SLF4J, you can avoid the isDebugEnabled() call, by using messaging formatting.
For example, instead of:
Object entry = new SomeObject();
logger.debug("The entry is " + entry + ".");
Use:
Object entry = new SomeObject();
logger.debug("The entry is {}.", entry);
The message formatting will not be evaluated unless debug is enabled.
So, for simple cases, you could avoid isDebugEnabled().
But in a case where building one of the parameters might be expensive, you would still want to use isDebugEnabled() (even with SLF4J).
For example:
if (logger.isDebugEnabled()) {
logger.debug("Here is the SQL: {}", sqlWrapper.buildSQL()); // assume buildSQL() is an expensive operation
}
In that case, you don't want to evaluate buildSQL() unless debug is actually enabled.
With SLF4J, there's some debate over using it always vs using it selectively. It really boils down to personal preference. You may want to use everywhere, to guard against another developer (unknowingly) changing your log message to something more complex/expensive in the future.