At one of our customer installations we had thousands of occurrences of the same exception. After a lot of well logged stacktraces (9332) the occurrence of the exception is still logged, but without stacktrace. After restarting the java process, the same thing: This time we had 17858 stacktraces and then only the exception occurrence itself.
There is a similar question here, but no answer...
Is it a log4j feature or bug? (I believe in the former, because I really like, what those apache guys do)
Any ideas?
Using Java 5 or better?
Then you're seeing:
The compiler in the server VM now provides correct stack backtraces for all "cold" built-in exceptions. For performance purposes, when such an exception is thrown a few times, the method may be recompiled. After recompilation, the compiler may choose a faster tactic using preallocated exceptions that do not provide a stack trace. To disable completely the use of preallocated exceptions, use this new flag:
-XX:-OmitStackTraceInFastThrow
Courtesy of the Java 5 release notes.
Sounds like a feature to me, at least if the stack traces really are identical. Why would you want to make your logs bigger (and thus harder to search) without getting any more information? Will check for configurability of this feature...
EDIT: I've had a look through the log4j code and there's no trace of it. This would strongly suggest that Robert's answer is correct. Nice VM feature IMO :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With