Saturday 24 March 2018

Log4j not printing the stacktrace for exception

I've noticed interesting behavior in the server logs on jdk 8. There was an exception without stack trace. After small research I have found that hotspot may apply some optimization to exceptions that are thrown too frequent, it simply trim stack trace) So I scrolled to the first occurrences of the exception and found my stack trace. Here is oracle docs describing it:

http://www.oracle.com/technetwork/java/javase/relnotes-139183.html

and you can disable it with -XX:-OmitStackTraceInFastThrow