[slf4j-user] Expressions on log statements to avoid log guading

Dario Garcia dario.garcia at 10pines.com
Thu Sep 12 00:05:40 CEST 2013


Hi everyone,

Does anyone knows if it's possible to use expressions on log variables to
avoid log guarding for costly operations?

For example, asuming that "receivedObject.getCurrentState()" is a costly
operation, what I'm doing now in my code is something like this:


if(LOG.isDebugEnabled()){
   LOG.debug("The received object has invalid state: {}",
receivedObject.getCurrentState() );
}


So I can avoid the cost of that operation when debug isn't enabled.
I would like to have some kind of expressions to avoid the extra IF:


LOG.debug("The received object has invalid state: {1.currentState}",
receivedObject)


I've seen on previous mail from Chris Pratt that someone suggested the
format from anodyzed, but I couldn't find documentation whether this was
implemented or not :

"...I would love to merge the formatter from
http://code.google.com/p/anodyzed directly into a pluggable SLF4j..."

Is this implemented or is it going to be implemented? Are there any
alternatives to what I'm doing?

Thanks in advance for your responses

-- 
*Darío García*
Agile Software Development
+54 (911) 6336-3707
*Office: +54 - 011 - 4311-8404*
dario.garcia at 10pines.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.qos.ch/pipermail/slf4j-user/attachments/20130911/47392d19/attachment.html>


More information about the slf4j-user mailing list