admin管理员组文章数量:1122846
In some cases exceptions being thrown are causing crashes in native library that we use before they get to be logged anywhere. So waiting for UncaughtExceptionHandler
to log them won't work. Even exceptions that were eventually caught caused crashes in native code in a few cases. And crash logs generated have no info on these exceptions.
Is there any way to log all exceptions as soon as they are created? Preferably it needs to work in a release build, without attached debugger.
In some cases exceptions being thrown are causing crashes in native library that we use before they get to be logged anywhere. So waiting for UncaughtExceptionHandler
to log them won't work. Even exceptions that were eventually caught caused crashes in native code in a few cases. And crash logs generated have no info on these exceptions.
Is there any way to log all exceptions as soon as they are created? Preferably it needs to work in a release build, without attached debugger.
Share Improve this question edited Nov 22, 2024 at 9:54 jonrsharpe 122k30 gold badges263 silver badges470 bronze badges asked Nov 22, 2024 at 9:53 maxpovvermaxpovver 1,6001 gold badge15 silver badges25 bronze badges 6- 1 stackoverflow.com/a/58325793/21105992 <- implement your own java.lang.Throwable class? – teapot418 Commented Nov 22, 2024 at 10:11
- 2 Perhaps you should explain in more detail about "causes crashes in native library". How does throwing an exception do that? – greg-449 Commented Nov 22, 2024 at 10:13
- 2 You don't want to do it. There are many exception thrown and caught in libraries. Even in SDK. – talex Commented Nov 22, 2024 at 10:32
- 4 You should fix the bugs in the native library, for sure. It should not crash due to some exception being thrown, not to speak of exceptions throw and caught somewhere (which suggests that they are entirely unrelated to the native library). – Holger Commented Nov 22, 2024 at 12:30
- 1 @maxpovver This does not change the fact that the bugs in the native library should be fixed rather than wasting time with the symptoms. – Holger Commented Nov 25, 2024 at 15:08
1 Answer
Reset to default 1If you know what methods are called from native code you can add try catch
in them.
You don't need to do it manually if you use some AOP library.
本文标签: How to log all Java exceptions on creationStack Overflow
版权声明:本文标题:How to log all Java exceptions on creation? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736304729a1932335.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论