java - 为什么 log4j 在(多次)重复相同异常后禁用堆栈跟踪?

标签 java log4j stack-trace

在我们的一个客户安装中,我们遇到了数千次相同的异常。在大量记录良好的堆栈跟踪 (9332) 之后,仍然记录了异常的发生,但没有堆栈跟踪。重新启动 java 进程后,同样的事情:这次我们有 17858 个堆栈跟踪,然后只有异常发生本身。

有个类似的问题here , 但没有答案...

这是 log4j 的特性还是错误? (我相信前者,因为我真的很喜欢那些 apache 家伙做的事)

有什么想法吗?

最佳答案

使用 Java 5 或更高版本?

然后你会看到:

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 5 release notes 提供.

关于java - 为什么 log4j 在(多次)重复相同异常后禁用堆栈跟踪?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1142007/

相关文章:

java - 在 java 中检索 slf4j 日志文件

java - 由于 kafka log4jappender,启动 yarn 作业时出现异常

java - java中如何获取主类名

java - 尝试打印堆栈跟踪时出现 StackOverflowError

java - 将主类添加到 list 文件中

java - 如何使用正则表达式解析出sql中的所有列?

java - Java GUI 中的退出冲突

java - Drools 流持久性 - joinTransaction 调用上没有 Activity 的 JTA 事务

python - 来自执行程序的 PySpark 日志记录

c# - ComboBox 强制崩溃(不是我的代码)