Search |
||
Sneaky, sneaky Log4JPosted by zarar on November 14, 2005 at 1:23 PM PST
So I found myself wanting to know if I could print the enclosing method of the current line of code being executed. A quick look at the reflection API didn't yield much. A little reflective thinking later, I came to the conclusion that it's impossible for the reflection API to tell me this since it explores binary files at the class level.
Thats when it struck me that Log4J does exactly what I want to do. It can print out the method and line number of the code for each
What Log4J ends up doing is that for each
Keep in mind that constructing stack traces is a fairly expensive operation. When an
However, in the logging scenario, the culprit is the call to the Although descriptive logging can provide good roll-back mechanisms in production code, the cost incurred by specifying method and line numbers when logging is simply too high. It seems like the pain of typing out the method name when logging is unavoidable. To some, this might come as old news but to many it'll make them change their log4j.properties. »
Related Topics >>
Performance Comments
Comments are listed in date ascending order (oldest first)
|
||
|
|