ASP.NET Exception Handling/Logging

后端 未结 7 852
感动是毒
感动是毒 2020-12-20 20:31

Is there an easy way to log all exceptions in an ASP.NET application? I\'m already logging unhandled exceptions through the Application_OnError event, but I want to perform

7条回答
  •  时光说笑
    2020-12-20 20:50

    ASP.NET Health Monitoring does this in an elegant and fairly automatic way (no need to manually catch exceptions):

    • ASP.NET Health Monitoring Overview
    • How To: Use Health Monitoring in ASP.NET 2.0

    When you click the first link, there is an example of how to enable and configure ASP.NET Health Monitoring. You need to configure it in web.config file.

    For logging to a DB, you can create the corresponsing table using the ASP.NET SQL Server Registration Tool: ASP.NET SQL Server Registration Tool (Aspnet_regsql.exe)

    I really like it. For manual logging, patterns & practices Enterprise Library's Logging Application Block might be something for you, but this is slightly off-topic.

    Matthias

提交回复
热议问题