Error-reporting framework for .net
is there an error-reporting-framework you would suggest for use in .net. I need possibilities like e-mail-reporting with fileappending to e-mail. The user should have the possibility to add information to the report and also should have the possibility to remove report-files, i.e. if they contains privacy-critical data开发者_JS百科. There also should be a possibility of taking an automated screenshot. The needed framework should also include error-reporting guis. It should give me the possibility to create own guis for error-reporting.
I already use log4net, but there it isn't possible, as far as i know, to show a gui for error-reporting to the user.
Would be nice if there are any advices,
Greetings, Martin
Have you tried Elmah? It does all the error handling elements you are talking of. You might look at Trac for the bug-tacking bits you want.
Kindness,
Dan
I am familiar with the "Microsoft Enterprise Library Logging Block" and "Log4Net" and both of these fit into your requirements (having multiple log listeners) Here is a page that compares these two: http://weblogs.asp.net/lorenh/archive/2005/02/18/376191.aspx
Roll your own exception handler. Use below code in your program.cs class. It will automatically Send mail when exception occurs.
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);
}
}
}
}
Check out the logging framework made by The Object Guy
Red Gate has a product called SmartAssembly that does error reporting. I haven't used it myself, but the company has a good reputation.
Check the Enterprise Library, you have a logging and an exception handling application log fully configurable and extensible.
There is Microsoft WER, however you need to register at Winqual and your company needs to have a VeriSign ID. Too much a hassle for many people.
Microsoft's Enterprise Library, latest version 4.1-October 2008 is widely used for Exception handling and logging among other things. There's also a nice GUI builder that will modify your app.config or web.config file.
You can also try log4net. I'm not sure about emailing, though. However, it is extensible. Plus you can get the source code!
精彩评论