try the Exception Management Application Block for .NET from Microsoft
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/emab-rm.asp

解决方案 »

  1.   

    在.Net建立自己的键值不用写入注册表啊,可以自己使用
    using System.Diagnostics;
    EventLog.CreateEventSource("你的键值", "Application"); 
    -------------------------------------
    在有的机器上web程序中可能返回错误权限不够,你可以用winfrom程序没有问题日志类的键值。
    这是我用来捕获错误写入日志类
    public class CatchError
    {
    const string EVENT_LOG_SOURCE = "BlueLight";
    public CatchError()
    {
    //
    // TODO: 在此处添加构造函数逻辑
    // }
    public static void SetLog(string pMessage) 
    {
    EventLog mEventLog = null;
    // make sure we have an event log
    if (!(EventLog.SourceExists(EVENT_LOG_SOURCE))) 
    {
    EventLog.CreateEventSource(EVENT_LOG_SOURCE, "Application"); 
    } if (mEventLog == null) 
    {
    mEventLog = new EventLog("Application");
    mEventLog.Source = EVENT_LOG_SOURCE;
    }

    // log the message
    mEventLog.WriteEntry(pMessage, System.Diagnostics.EventLogEntryType.Error);
    }
    }
      

  2.   

    向 saucer(思归/MVP)和 CMIC(大象)学习。顶
      

  3.   

    global.asax<%@ Import Namespace="System" %> 
    <%@ Import Namespace="System.Diagnostics" %> 
    <script runat="SERVER">
    Public Sub Application_OnError(Sender As Object,E As EventArgs)
    Dim lasterror As Exception = Server.GetLastError()
    Dim logname As String = "Shop Log"
    Dim message As String = "--------------------------" & Chr(10) & "地址:" & Request.RawUrl & Chr(10) & "方式:" & Request.RequestType() & Chr(10) & "客户:" & Request.UserHostAddress & Chr(10) & "信息:" & lasterror.ToString
    If Not EventLog.SourceExists(logname) Then EventLog.CreateEventSource(logname,logname)
    Dim log As New EventLog
    'log.Source = logname
    log.WriteEntry(logname,message,EventLogEntryType.Error,7036,20)
    log = Nothing
    End Sub
    </script>