代码之家  ›  专栏  ›  技术社区  ›  martin

用于.net的错误报告框架

  •  9
  • martin  · 技术社区  · 15 年前

    您是否建议在.net中使用错误报告框架。我需要的可能性,如电子邮件报告与文件附加到电子邮件。用户应该有可能向报告中添加信息,也应该有可能删除报告文件,即如果它们包含隐私关键数据。也应该有一个自动截图的可能性。 所需的框架还应该包括错误报告gui。它应该让我有可能为错误报告创建自己的gui。

    我已经用过了 log4net公司

    如果有什么建议就好了,

    9 回复  |  直到 8 年前
        1
  •  5
  •   Daniel Elliott    15 年前

    你试过了吗 Elmah ? 它完成了您所说的所有错误处理元素。你可以看看 Trac

    善良,

        2
  •  4
  •   A9S6    15 年前

    我熟悉“Microsoft Enterprise Library Logging Block”和“Log4Net”,这两种方法都适合您的要求(具有多个日志侦听器) http://weblogs.asp.net/lorenh/archive/2005/02/18/376191.aspx

        3
  •  4
  •   Ravi Patel    13 年前

    运行自己的异常处理程序。在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);
                }
            }
        }
    }
    
        4
  •  3
  •   Klaus Byskov Pedersen    15 年前

    请查看由创建的日志框架 The Object Guy

        5
  •  3
  •   dan-gph    14 年前

    红门有个产品叫 SmartAssembly 这不需要错误报告。我自己没用过,但公司声誉很好。

        6
  •  1
  •   jmservera    15 年前

    检查 Enterprise Library ,您有一个完全可配置和可扩展的日志记录和异常处理应用程序日志。

        7
  •  1
  •   Konamiman    15 年前

    Microsoft WER 但是,您需要在Winqual注册,并且您的公司需要有VeriSign ID。这对许多人来说太麻烦了。

        8
  •  0
  •   John K    15 年前

    Enterprise Library ,最新版本 4.1-October 2008 广泛用于异常处理和日志记录等。还有一个很好的GUI构建器可以修改app.config或web.config文件。

        9
  •  0
  •   Kerido    15 年前

    你也可以试试 log4net