为什么 log4j 在(大量)重复相同异常后禁用堆栈跟踪?

发布于 2024-07-27 17:20:20 字数 368 浏览 1 评论 0原文

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

有一个类似的问题 这里,但没有答案...

这是 log4j 功能还是错误? (我相信前者,因为我真的很喜欢那些阿帕奇人所做的事情)

有什么想法吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

等数载,海棠开 2024-08-03 17:20:20

使用 Java 5 或更好的版本?

然后你会看到:

服务器虚拟机中的编译器现在为所有“冷”内置异常提供正确的堆栈回溯。 出于性能目的,当此类异常抛出几次时,该方法可能会被重新编译。 重新编译后,编译器可能会使用不提供堆栈跟踪的预分配异常来选择更快的策略。 要完全禁用预分配异常的使用,请使用以下新标志:-XX:-OmitStackTraceInFastThrow

Java 5 发行说明

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.

年华零落成诗 2024-08-03 17:20:20

对我来说听起来像是一个功能,至少如果堆栈跟踪确实相同的话。 为什么您想让日志变得更大(从而更难搜索)而不获取更多信息? 将检查此功能的可配置性...

编辑:我查看了 log4j 代码,但没有任何痕迹。 这强烈表明罗伯特的答案是正确的。 IMO 不错的虚拟机功能:)

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 :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文