2011-01-24 78 views

回答

6

有幾種方法可以做到這一點,但我會建議設置ELMAH

它將使用堆棧跟蹤記錄異常並提供一個Web界面來查看它。

還有其他記錄器(log4net),您可以編寫自己的記錄(Exception.ToString()將提供大多數追蹤錯誤所需的信息),但我發現ELMAH很容易上手。

+0

任何想法的Apache/PHP環境 – ravisoni 2014-05-19 07:17:50

1

檢查錯誤日誌。儘管它們的位置取決於你的serer設置。

1

如果錯誤發生在您的ASP.NET應用程序上,您可以捕獲錯誤並將它發送給自己。

您可以捕獲錯誤Global.asax文件...

Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs) 
    ' Code that runs when an unhandled error occurs 

    Dim sb As New StringBuilder 
    sb.AppendFormat("Page Location: {0}", Context.Request.RawUrl) 
    With Server.GetLastError.GetBaseException 
     sb.AppendFormat("Message: {0}", .Message) 
     sb.AppendFormat("Source: {0}", .Source) 
     sb.AppendFormat("Method: {0}", .TargetSite) 
     sb.AppendFormat("Stack Trace: {0}", .StackTrace) 
    End With 
    Dim ErrorMsg As String = sb.ToString() 
    ' Post thee error to a logger... 

End Sub 

G.

+0

我建議你看看Exception.ToString的`結果()`。包含所有上述內容,您將放入字符串生成器。 – Oded 2011-01-24 10:27:27