Although in some tutorials, for example here (Parametrized logging section), said that Logback message {}
parametrization help us to avoid unnecessary calculation in logging data (if logging level is not DEBUG):
logger.debug("The bonus for employee {} is {}",
employee.getName(), employeeService.calculateBonus(employee));
I tested (on logback version 1.2.3
) that this optimization works only for unnecessary toString()
of parameter object - as this works for log4j.
Logback documentation doesn't cover this detail.
So, we have to use isDebugEnabled() for all 'expensive' logging, do we?