Hi guys,
I've heard many times in various articles about how calling getLogger()
over and over has a performance hit on your application. Is this
actually true? I just did a very simple bench mark, and I just can't
see it. Were things handled differently in older JVMs or something like
that? Or did log4j used to have a problem in that area?
Here's my results...
In the following test, I used the root logger 1,000,000 times...
==> test-tntlogger5.log <==
INFO | root | Thu Dec 01 18:00:02 2005 | 13 | Test this : 999998
INFO | root | Thu Dec 01 18:00:02 2005 | 13 | Test this : 999999
INFO | root | Thu Dec 01 18:00:02 2005 | 16 | time : 60625
In the following test, I called getLogger() over and over 1,000,000
times, inside a utility class, which gets a StackTraceElement, passing
the classname from the stack trace in as the category, and then logs the
message.
==> test-tntlogger6.log <==
INFO | Test.main | Thu Dec 01 18:06:31 2005 | 13 | Test this : 999998
INFO | Test.main | Thu Dec 01 18:06:31 2005 | 13 | Test this : 999999
INFO | Test.main | Thu Dec 01 18:06:31 2005 | 16 | time : 63029
So, we've got 0.060 ms per log entry the first run, and 0.063 ms per log
entry the second run, when calling getLogger() over and over.
So, what's up with people writing articles about it's performance problems?
__
This communication is intended for the use of the recipient to whom it
is addressed, and may contain confidential, personal, and or privileged
information. Please contact us immediately if you are not the intended
recipient of this communication, and do not copy, distribute, or take
action relying on it. Any communications received in error, or
subsequent reply, should be deleted or destroyed.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]