On Thu, 22 Apr 2004, Robert Pepersack wrote:

| It shouldn't be significant.  On page 41 of the book, Ceki says, "This is
| an insignificant overhead because evaluating a logger takes less than 1% of
| the time it actually takes to log.  If a method contains multiple log
| statements, it may be possible to factor out the tests."
|
| I factor out the tests, because I'm sensitive to performance.

What Ceki just have to be talking about here, is that if you have multiple
log lines in one bunch of code (e.g. a method), then instead of checking
the log-flag many times, you check it once for the entire method (using
the debug-boolean you mention, but e.g. for each method invocation), and
then use that several times. Also, you may do
 if (log.isDebugEnabled()) {
     log.debug("one line");
     log.debug("one more line");
 }

.. if you just have to have many lines in a row - I often do this to
"dump" e.g. some state information - it often looks nicer than using one
log line with tons of info.

You should do some performance measurements on your code - you'll realize
that what you're "sensitive" about probably won't account for a per-mille
of your code's time usage. See - if you have -one- database lookup in e.g.
a Servlet's get method, this will take so insanely much more time than the
checking of that boolean (probably a million times or so..) that it
-REALLY- doesn't matter anymore!

Endre.


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

Reply via email to