> Using JDK1.4 I wrap my logger calls in if statements
> if(logger.isLoggable(Level.XXXX) {
>       logger.xxx(<message>);
> }
> If you are privy to a better solution let me know.

No, that's fine. I didn't want to imply that you're writing bad code, I
just wanted to say that not all developers think about performance when
they produce logging code.

> In production code the 'if' nearly always evaluates to false and the logging
> is not performed. This requires the JVM to perform one method call, may even
> be inlined by a smart compiler. Putting a wrapper layer around this will
> require a call to a conversion method and then a call to the isLoggable().
> This at best doubles the number of method calls which are far more processor
> expensive than the body of the 'isLoggable()' itself. Should the
> 'isLoggable()' be inlined then this translation step becomes even more
> expensive.
> Incidentally our logging is stored in a central database after being
> transmitted across a network. The server pools these log records in memory
> before writing them to the database. This persistence is a performance
> problem does that make us bad programmers.

I'm not accusing you of being a bad programmers. I think you got me
wrong. Sorry for that. And furthermore, I don't like to start a
discussion about logging and performance. This discussion has been held
many time on the log4j and avalon mailing lists and can be looked up in
the archives. I don't have anything useful to add.

> I do not think that the gain in flexibility out-weighs the loses in
> performance. I would prefer to stick to log4j and spend the extra day
> learning the simple API rather than produce more inefficient code.

You always have to decide which one is more important. Sometimes it's
flexibility, sometime it's speed.

> I have to use 1.1.8 JDK(Personal Java 3.1) to program a Windows CE device,
> that does not mean I would argue against adopting a newer standard which
> would benefit the majority. I would think of a way to get round the problem
> rather than hold back the adoption of an obviously superior technology. If
> every body thought your way I would still be writing 'C' using command line
> tools. :)

Sorry, but I don't understand the relationship between my opinion and
your comment here.

Jeremias Märki


Postfach 3954 - Rhynauerstr. 15 - CH-6002 Luzern
Fon +41 41 317 20 20 - Fax +41 41 317 20 29
Internet http://www.outline.ch

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to