|There's more than one way to do things|
log4perl and efficiencyby erwan (Sexton)
|on Sep 12, 2011 at 16:46 UTC||Need Help??|
erwan has asked for the wisdom of the Perl Monks concerning the following question:
Facing some efficiency issues with a quite complex program, I used NYTProf to profile it. I noticed that the logging operations (using Log4perl) require a significant amount of time (about 25%), so I tried to disable logging by setting the log level to OFF. Nothing is logged (of course), but according to NYTProf the time taken by Log4perl is still the same. I thought that as soon as level was OFF calls to log4perl would have exited immediately, but it seems there are a lot of internal computations whatever the level (?).
I have already optimized the most frequent calls in the following way:
and I was very surprised when I saw that even this simple call to is_trace() (when the log level is OFF) is very costly (takes 30% of the time spent in a sub called very often).
Of course I can create my own condition like
but it doesn't seem very elegant to add my own "optimized level" to the usual ones. Do you have any other ideas? Maybe something I missed about Log4perl? Thank you!