Hi Xav,

the code that test  isDebugEnabled() is valid only for log4j 1.x.

If you use slf4j (provided by Pax Logging):

1/ you don't have to check the log level (slf4j does it for you)
2/ I strongly advice to use

logger.debug("Entry number: {} is {}", i, String.valueOf(entry[i]))

Like this, the Strings are evaluated when required (and not always before as in your statement).

Regards
JB

On 07/03/2014 11:37 AM, xav wrote:
Hi all,

I have done a code review on a OSGI (Karaf) project, and I have a simple
question about the logging perf.

With the default logger in karaf (pax logging), is there mandatory to test
all logger.debug by:

if(logger.isDebugEnabled() {
    logger.debug("Entry number: " + i + " is " + String.valueOf(entry[i]));
}

or just write:
logger.debug("Entry number: " + i + " is " + String.valueOf(entry[i]));

Thanks for answers;



--
View this message in context: 
http://karaf.922171.n3.nabble.com/Logging-perf-tp4033974.html
Sent from the Karaf - User mailing list archive at Nabble.com.


--
Jean-Baptiste Onofré
[email protected]
http://blog.nanthrax.net
Talend - http://www.talend.com

Reply via email to