Logger performance

K

Kenneth P. Turvey

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I was looking at the Logger classes the other day and I read some claims
about the performance of the Logger that I found a bit hard to believe.

Ideally what one would like is a system like the assertion system where
logging code is only executed when it is above the level being filtered
by the logging system so code like this:

thisLogger.finest("My info: " + SomeObject.performComplexCalculation());

would not execute except when the user was requesting logging at the
finest level.

I don't believe the Logger is handled this way. It would require
compiler support that I don't believe exists, wouldn't it?

Am I correct in understanding that logging should not be used in inner
loops, even for debugging (if it will be in the code in production)?

Thanks.

- --
Kenneth P. Turvey <[email protected]>
http://kt.squeakydolphin.com (not much there yet)
Jabber IM: (e-mail address removed)
Phone: (314) 255-2199

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFDLeDq3naBnF2rJNURAtyZAKDFGo4CopQkwj3l+UWjXSAd/9e4tACfWX6J
5MomPDKF+vrHRTPQku8Lpuo=
=SMUy
-----END PGP SIGNATURE-----
 
S

Scott Ellsworth

Kenneth P. Turvey said:
That's too bad. Having all this code for logging really clutters the
code. There must be a better way.

I have never found

if (logger.isLoggable(Level.FINEST)) {
logger.finest("count: "+count);
}

to be all that bad, but then I tend to have some very distinct patterns
in my logging code. For example, I log entry and exit at the top and
bottoms of methods, so I tend not to see those lines.

I suspect aspects are really the only way to get this to be clean, or
log/nolog versions of the code generated from some template or Aspect
system.

Scott
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Logger performance 3
Array declaration compiler bug? 3
Java 1.6 13
Executor 8
Binomial Simulation 16
Parameters (command line, preferences, user input) 1
Beowulf clusters 9
Simple GUI problem 1

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top