[slf4j-user] Varargs for Logger methods

Bjorn Danielsson bjorn at implior.se
Sat Oct 14 18:21:08 CEST 2006


"Martin Gilday" <martin.lists at imap.cc> wrote:
> Hi,
> I have just been evaluating SLFJ, looking to move over from JCL.  I was
> pleased to come across the conveience log statements that reduce the
> need for isDebugEnabled if statements. My immediate reaction to this was
> that it would be a great place to use varargs.  Searching this mailing
> list showed that this had been discussed before, with the outcome that
> it would not be added at the present time.  Has there been any more
> thought given to integrating vararg support?  Alternatively has any side
> projects or extensions been produced that do this for log4j/logback?

Varargs is just syntactic sugar for "new String() { x,y,z }", so it
still allocates memory, not just stack/register space. At least this
is how it works in java 1.5.0. It will slow down your code compared to
using isDebugEnabled, due to increased number of garbage collections.

I am not against use of vararg, because there are plenty of other
arguments for it. I am just mentioning this fact about the current
implementation of varargs.

-- 
Björn Danielsson  <bjorn at implior.se>
Implior AB  <URL:http://www.implior.se>



More information about the slf4j-user mailing list