2009-08-06 169 views
2

我刚接手,有很多的代码了下方例外刚好赶上和Console.Write(XXX)有一个应用程序。ASP.NET MVC异常日志记录

我想改变这种做法,我有一个简单的日志审查凡事都有Console.write()现在。

什么是让这个设置在asp.net mvc的有一个文件来查看IIS服务器上的最简单的方法。

try 
{ 
    SmtpClient c = new SmtpClient("mail.xxx.org"); 
    c.Send(msg); 
} 
catch (Exception ex) 
{ 
    Console.Write(ex.Message.ToString()); 
} 
+0

还有其他类似的问题:ASP.NET MVC。请参阅... http://stackoverflow.com/questions/1032373/asp-net-mvc-exception-logging-combined-with-error-handling – 2009-08-06 05:32:25

+1

此外,[本博客](http://blog.dantup。 me.uk/2009/04/aspnet-mvc-handleerror-attribute-custom.html)对如何记录[HandleError]属性捕获的错误有很好的解释。 – 2009-08-06 05:28:30

回答

5

您可能想试试ELMAH库。

检查the project site的一些例子。

斯科特Hanselman的也写a blog post或两个一下吧。

+0

在<2分钟内完成了设置 – leora 2009-08-06 05:32:39