Java中崩溃报告的策略/技术 [英] Strategies/techniques for crash reporting in Java

查看:154
本文介绍了Java中崩溃报告的策略/技术的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个新的Java桌面应用程序,并希望包括一个崩溃报告工具 - 你知道那种事情 - 程序崩溃,弹出框请求用户单击确定发送等。

I'm developing a new Java desktop application and would like to include a crash reporting facility - you know the kind of thing - program crashes, box pops up asking user to click okay to send it, etc.

我很乐意将错误发送回我们的服务器 - 可能通过一个简单的Web服务。我更不确定是如何实现捕获故障的机制?

I'm comfortable with how the error will be sent back to our servers - probably via a simple web service. What I'm more unsure about is how the mechanism for capturing the failure should be implemented?. I would welcome any advice from anyone that has implemented something similar.

推荐答案

我看到三种情况:


  1. 灾难。 JVM本身已经死亡或死亡。你不能假设你的代码将能够工作,例如你不能分配任何内存。因此,在这种情况下,您不能合理地希望能够发送任何诊断。你可以希望的最好的是有一些诊断,如核心转储留在死程序的灰烬。


    在这种情况下,你可以在启动一个新的运行查找这样的碎片和

  1. Catastrophes. The JVM itself is either dead or dying. You cannot assume that any of your code will be able to work - for example you can't allocate any memory. Hence in this case you can't reasonably hope to be able to send any diagnostics. The best you can hope for is to have some diagnostics such as core dumps left in the ashes of the dead program.

    In this case you could on startup of a new run look for such debris and suggest that the user gather it or, rather more effort attempt to assemble a diagnostic package yourself.

低级应用程序代码不会捕获异常,或许一个RunTime异常,例如NullPointer异常。在这种情况下,你可以在你的主(假设你有一个),你可以捕获异常,并有一些希望,你的Crash Reporter代码将工作。
将异常传递给Crash Reporter。

The low-level application code does not catch an exception, perhaps a RunTime exception such as a NullPointer exception. In this case you could in your main (assuming you have one) you could catch Exception and have some hope your that your Crash Reporter code will work. Pass the exception, and it's stack trace, to the Crash Reporter.

您的低级别代码捕获的东西真的不健康。不足以终止过程,但值得报告。在这里你不仅有手的例外,但其他上下文信息。

You low level code catches something really unhealthy. Not enough to terminate process, but worth reporting. Here you not only have the exception to hand but other contextual information. We have rather more to send to the Crash Reporter.

这篇关于Java中崩溃报告的策略/技术的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆