[slf4j-user] Java 5 version of SLF4J?

Ceki Gulcu listid at qos.ch
Fri Apr 25 22:43:45 CEST 2008



Joern Huxhorn wrote:
> Simon Kitching wrote:
>> The SLF4J fake-varargs approach, where the api allows 0,1 or 2 params is
>> slightly better, as it avoids the "new Object[]" call. But for best
>> performance, isDebugEnabled should be used anyway.
>>
>> Regards,
>> Simon
> 
> Hi Simon.
> 
> The above isn't the case for logback since calls with explicit arguments 
> (instead of argument array) are simply wrapped in an Object[] and 
> forwarded to the Object[]-implementation of the method.
> 
> Joern.

Hello Joern, Hello Simon,


I just quickly looked at the code and I believe that parameters are
aggregated into Object[] *after* a decision is made to log. Filters in
appenders may override this decision, but that happens much later in
the processing pipeline.

As for Simon's argument that the extra parameters need to be pushed
onto the execution stack, I think that pushing one or two arguments
onto the stack takes about or less than a nanosecond on most machines,
hardly noticeable even if you log millions of times a second.
Creating an Object[] takes about 20 nanoseconds, a lot more than
pushing a parameter but still only 20 nanoseconds.

Cheers,

-- 
Ceki Gülcü
QOS.ch is looking to hire talented developers in Switzerland.  If
interested, please contact c e k i AT q o s . c h




More information about the slf4j-user mailing list