我应该如何在ASP.NET中记录异常? [英] How should I log exceptions in ASP.NET?

查看:113
本文介绍了我应该如何在ASP.NET中记录异常?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何记录异常?我从来没有尝试过登录.NET。也不要将异常转储到txt(或二进制)文件。我不需要一个文本文件,只是一种使用文件和行#查看日志的方法。

How should I log exceptions? I never tried logging in .NET before. Nor try to dump exceptions to a txt (or binary) file. I dont require a text file, just a way to view the logs with the file and line #.

-edit-使用asp.net

-edit- using asp.net

推荐答案

ELMAH 是非常好的,如果你使用ASP.NET。我最喜欢的关于ELMAH的功能之一是无需构建UI来查看记录的异常; ELMAH提供一个处理程序来报告你的异常。但是,我从来没有使用它来记录异常以外的任何东西。

ELMAH is particularly nice if you're using ASP.NET. One of my favorite features about ELMAH is not having to build the UI to view logged exceptions; ELMAH provides a handler that will report your exceptions. However, I've never used it for logging anything other than exceptions.

log4net和 Microsoft的EntLib 是其他一些想法。如果您真正需要的只是异常日志记录,那么它们可以提供更多的功能。

log4net, and Microsoft's EntLib are some other ideas that come to mind. These provide a lot more functionality than what you may need if all you really need is just exception logging.

另外,您可以考虑性能计数器如果您真正想要做的是测量您的应用程序再次,使用性能计数器的好处是,在发布数据后,您不必担心构建UI来查看/查询数据。

Also, you may consider performance counters if what you're really trying to do is measure your application. Again, the benefit of using performance counters is that after publishing the data, you won't have to worry about build the UI to view/query the data.

这篇关于我应该如何在ASP.NET中记录异常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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