Micronaut:正确记录“未接收”不出现在System.err上的例外
我有一个有关捕获“未被发生”例外的问题,该异常出现在system.err
,绕过日志记录配置上:所有其他日志消息都在system.out
(在我的情况下是JSON-FORMATT的)。但这并没有发生异常和堆叠轨迹“已记录”到system.err!
我已经意识到这种情况至少在两种情况下发生:
- 通过
executorService
(如“计划任务”章)。我已经在方法中添加了@retryable
注释;但是在所有重试失败后,最后一次失败重试的“最终”异常出现在system.err
及其堆栈跟踪(其他较早失败的恢复效果do not ) ,似乎它们被引擎盖下的重试的“机制”捕获。 - 除了失败的健康指标(通过子类
avctracthealthedicator
)实现的例外(它们是实现的)。
我已经尝试实现自己的taskexceptionHandler
,替换默认一个(在”计划任务“章);和/或通过System.Seter.seterr(System.out)
在main
方法中构建/设置Micronaut应用程序上下文之前。但是我的测试案例证明,似乎没有任何帮助。
我是否错过了Micronaut文档中的一章? 感谢您的提示。
关于
基督徒
I've a question regarding capture of "uncaught" exceptions, which appears with stack trace on System.err
, circumventing logging configuration: All the other log messages appear properly formatted on System.out
(JSON-formatted in my case). But this doesn't happen with Exceptions and stack traces "logged" to System.err!
I've recognized this to happen under at least two circumstances:
- Asynchronous execution of tasks (HTTP requests in my case) via
ExecutorService
(as mentioned in "Scheduled Tasks" chapter). I've added@Retryable
annotation to the method; but after all retries fail, "final" Exception thrown by last unsuccessful retry appears onSystem.err
with its stack trace (the other ones thrown by earlier failed retries do not appear, seems they are caught by retry "mechanism" under the hood). - With Exceptions thrown by failed Health indicators (they are implemented by subclassing
AbstractHealthIndicator
).
I've tried implementing my own TaskExceptionHandler
, replacing the default one (also mentioned in "Scheduled Tasks" chapter); and/or by adding System.setErr(System.out)
in main
method before building/setup of Micronaut Application Context. But nothing seems to help as my test cases attest.
Have I missed a chapter in Micronaut's documentation?
Thanks for any hints.
Regards
Christian
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的赌注是,Micronaut不提供为设定全球未知的异常处理程序的工具,因为这是由更广泛的JRE支配的。我们已经通过
thread> thread.thread.html#setDefaultuncectexceptionhandler
My wager is that Micronaut doesn't provide tools for setting a global uncaught exception handler because that's governed by the wider JRE. We've solved the problem in a few of our services with
Thread.html#setDefaultUncaughtExceptionHandler
by doing something like this at application startup: