When writing to the log file at anything lower than the Info level, it is considered best practice to check the level before passing a string expression that includes any string manipulation. This is because the string manipulation itself has some performance overhead that need not be consumed if you are not going to log at that level of detail. So it is common practice to check the log level before executing the log method (see example below). But Gosu provides an overloaded log method signature that takes a block parameter instead of an actual string parameter. This version of the method obviates the need to explicitly check the log level because the method does the same check before evaluating the block. This gives the perf advantage of not executing any string manipulations unless you are at the right level AND you do not have to have a specific check for the level.
Always use the block method signature for any log commands at Debug, Trace, or Info levels. Do not put in specific checks for those levels.
abstract class AbstractISOLocationFinder<T extends AbstractISOLocationSearchResult> implements ISOLocationFinder<T> {
protected function processForNonEmptyHighAndLowAddress(result: List<T>, criteria: ISOLocationSearchCriteria, _dbConnection: Connection): List<T> {
//INCORRECT
if (_LOGGER.isDebugEnabled()) {
_LOGGER.debug(DisplayKey.get("logging.entering", "AbstractISOLocationFinder", "processForNonEmptyHighAndLowAddress"))
}
Correct usage of Logger statements
_LOGGER.debug(\->DisplayKey.get ("logging.entering", "AbstractISOLocationFinder", "processForNonEmptyHighAndLowAddress"))