Re: Measuring logging performance impact (including string concatenation)

2010-02-23 Thread Ceki Gülcü
NDC can be simulated with MDC, and the slf4j-ext module comes with such an implementation. See http://slf4j.org/xref/org/slf4j/NDC.html. Moreover, MDC fits most problems better than NDC, but your use case might warrant NDC instead of MDC. With regards to the varargs, for one or two arguments ther

Re: Measuring logging performance impact (including string concatenation)

2010-02-23 Thread Michael Erskine
If you're concerned about performance then just code sensibly: when a call is going to be expensive just do what's right and check the logger level. Who cares if it involves an extra if statement? Regards, Michael Erskine. - To u

Re: Measuring logging performance impact (including string concatenation)

2010-02-23 Thread James A. N. Stauffer
Thanks Ceki! Two of our projects use NDC so I'll probably leave them with log4j but I might switch the j.u.l calls to SLF4J. I see that j.u.l does support parameterized messages but they don't use varargs so you have to explicitly create an extra Object[] and it requires you to pass the level. O

Re: Measuring logging performance impact (including string concatenation)

2010-02-23 Thread Ceki Gülcü
Hello James, There is no perfect way to measure the overhead of parameter constructions, but 200 nanosecond is a reasonable lower bound. So, if you call a disabled logger 1'000'000 times you will see an overhead of at least 200 milliseconds. Nothing to call home about. However, the toString() met

Measuring logging performance impact (including string concatenation)

2010-02-23 Thread James A. N. Stauffer
Our applications have extensive use of logging (most commons-logging over log4j, and j.u.l). We use j.u.l for code that runs in an applet so we don't incur the cost of an extra jar download. Since we don't have access to message formats, we incur the cost the log message string concatenation even