Hello,

maybe I'm wrong, but I from the description

http://www.slf4j.org/faq.html#logging_performance

I understand, that the following two statements should be equivalent, 
considering the current logging level is INFO or higher:

// first
if (logger.isDebugEnabled()) {
logger.debug("Msg: " + someObject);
}

// second
logger.debug("Msg: {}", someObject);

But they aren't, if you want to call a method from the object:

// Object might be null, for some reason in some logging levels
Object o = null;

// Everythings fine
if (logger.isDebugEnabled()) {
logger.debug("Msg: " + o.hashCode());
}

// NullPointerException is thrown, since o is null for DEBUG level
logger.debug("Msg: {}", o.hashCode());

Is this a bug or intended behaviour? I couldn't find any hints in the 
documentation.

Greetings,

Aaron Kunde
-- 
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de
_______________________________________________
slf4j-user mailing list
[email protected]
http://mailman.qos.ch/mailman/listinfo/slf4j-user

Reply via email to