Thursday, 15 October 2015

log4j vs slf4j

I didn't know that slf4j is another abstraction for ex. log4j. Slf4j independence application from using ex. log4j or common logs. It doesn't log anything if behind it there isn't any logging library. 
Slf4j gives something useful in its interface - something like string format. You can write

LOGGER.debug("This my log in class {} and method {}", getName(), "my method");
and then, when this class is at higher logging level then debug it doesn't concatenate string)


I think it doesn't  protect us from writing sometime like this:

if(LOGGER.isDebug()){
     String s = someLongExecutionOperation();
     LOGGER.debug(s);
}

No comments:

Post a Comment