在我的应用程序日志(使用 log4j)中,我看到了 NullPointerException,但没有堆栈跟踪。我知道作为一种优化,当异常发生多次时 - jvm 停止生成堆栈跟踪。问题是前段时间发生了异常,我所有的日志都充满了异常而没有堆栈跟踪。有没有办法“重置”这个机制,所以下一个抛出的异常将打印完整的堆栈跟踪?我不想重新启动应用程序,因为很难重现此错误,并且重新启动可能会导致“消失”...
谢谢!
最佳答案
尝试使用以下 JVM 属性运行:
-XX:-OmitStackTraceInFastThrow
来自 Release Notes :
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
.
关于java - 没有堆栈跟踪的重复异常 - 如何重置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4659151/