记录问题 [英] Logging question

查看:78
本文介绍了记录问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

崩溃时记录应用程序数据的最佳解决方案是什么?

是否有可能以未处理的期望将数据记录为XML或其他格式,其中数据将指定文件,行以及可能的转储? class ="h2_lin">解决方案

如果使用Vista,则可以使用其应用程序恢复从崩溃中恢复.这里有关于CP的文章: C#中的Vista应用程序崩溃恢复 [ ^ ]

如果您要去保存数据,那么我将使其尽可能简单.如果您拥有Exception对象,那么堆栈跟踪,异常类型名称和异常消息将是一个很好的开始.如果InnerException不为null,那么您也希望获得它.出于错误记录的目的,我只是进行序列化.它仍然很容易通过电子邮件发送,可以保存为XML格式,并具有您需要的数据.而且几乎没有什么地方会出错,因此您极不可能获得异常,该异常会触发异常处理程序,从而引发异常,从而无限期触发异常处理程序.

很显然,如果您的应用程序处理安全数据,那么您必须将其保存为加密格式.这仍然可以使用序列化;您只需要将其保存到CryptoStream而不是FileStream


What is best solution for logging app data when crashed.

Is it possible to log data into XML or other formats as unhandled expections, where the data woud specify file, line and possibly a dump?

解决方案

If you use Vista, then you can use its Application Recovery to recover from a crash. There''s an article on CP for it here: Vista Application Crash Recovery in C#[^]

If you''re going to save data, then I would make it as simple as possible. If you''ve got the Exception object, then the stack trace, exception type name and exception message would be a good start. You''d also want to get that for the InnerException, if it''s not null. For the purposes of error logging, I''d just serialisation. It''s still easily emailable, can be saved into XML format, and will have the data you need. And there''s very little which can go wrong with it, so you''re highly unlikely to get an exception, which would trigger the exception handler, which would raise an exception, which would trigger the exception handler ad infinitum.

Obviously if your application handles secure data, then you''ve got to save it in encrypted format. This can still use serialisation; you just need to save it to a CryptoStream instead of a FileStream


这篇关于记录问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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