提问人:martin 提问时间:12/15/2009 最后编辑:Ognyan Dimitrovmartin 更新时间:2/9/2017 访问量:9250
.net 的错误报告框架
Error-reporting framework for .net
问:
您是否建议在 .NET 中使用错误报告框架。我需要诸如电子邮件报告之类的可能性,并将文件附加到电子邮件中。用户应该有可能向报告添加信息,也应该有可能删除报告文件,即如果它们包含隐私关键数据。还应该有可能进行自动截屏。 所需的框架还应包括错误报告 gui。它应该使我有可能创建自己的 gui 来报告错误。
我已经使用了log4net,但据我所知,不可能向用户显示用于报告错误的GUI。
如果有任何建议就好了,
问候,马丁
答:
你试过艾尔玛吗?它执行您所说的所有错误处理元素。您可能会在 Trac 上寻找您想要的 bug 处理位。
恩
担
检查企业库,您有一个完全可配置和可扩展的日志记录和异常处理应用程序日志。
我熟悉“Microsoft 企业库日志记录块”和“Log4Net”,这两者都符合您的要求(具有多个日志侦听器) 以下是比较这两者的页面: http://weblogs.asp.net/lorenh/archive/2005/02/18/376191.aspx
评论
有Microsoft WER,但是您需要在Winqual注册,并且您的公司需要有一个VeriSign ID。 对许多人来说太麻烦了。
Microsoft 的企业库,最新版本 4.1-2008 年 10 月广泛用于异常处理和日志记录等。还有一个不错的 GUI 构建器,可以修改您的 app.config 或 web.config 文件。
查看 The Object Guy 制作的日志框架
您也可以尝试log4net。不过,我不确定电子邮件。但是,它是可扩展的。另外,您可以获取源代码!
Red Gate 有一款名为 SmartAssembly 的产品,可以进行错误报告。我自己没有用过,但公司口碑很好。
评论
滚动自己的异常处理程序。在program.cs类中使用以下代码。当发生异常时,它会自动发送邮件。
using System;
using System.Windows.Forms;
using System.Net;
using System.Net.Mail;
using System.Threading;
namespace ExceptionHandlerTest
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.ThreadException +=
new ThreadExceptionEventHandler(Application_ThreadException);
// Your designer generated commands.
}
static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
{
var fromAddress = new MailAddress("your Gmail address", "Your name");
var toAddress = new MailAddress("email address where you want to receive reports", "Your name");
const string fromPassword = "your password";
const string subject = "exception report";
Exception exception = e.Exception;
string body = exception.Message + "\n" + exception.Data + "\n" + exception.StackTrace + "\n" + exception.Source;
var smtp = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
};
using (var message = new MailMessage(fromAddress, toAddress)
{
Subject = subject,
Body = body
})
{
//You can also use SendAsync method instead of Send so your application begin invoking instead of waiting for send mail to complete. SendAsync(MailMessage, Object) :- Sends the specified e-mail message to an SMTP server for delivery. This method does not block the calling thread and allows the caller to pass an object to the method that is invoked when the operation completes.
smtp.Send(message);
}
}
}
}
评论
上一个:制作日志文件和错误报告
下一个:WCF 服务中出现错误报告?
评论