我对日志记录很陌生。我在我的事件日志中得到了这个乱码。找不到源 (xyAMP) 中事件 ID (0) 的描述。本地计算机可能没有必要的注册表信息或消息 DLL 文件来显示来自远程计算机的消息。您可以使用 /AUXSOURCE= 标志来检索此描述;有关详细信息,请参阅帮助和支持。以下信息是事件的一部分:来源:System.Web
在诊断错误时如何使这更有帮助。这是我的日志记录代码。
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs) Dim ctx As HttpContext = HttpContext.Current
Dim ex As Exception = ctx.Server.GetLastError()
Dim data As String = String.Empty
Dim referer As String = IIf(ctx.Request.ServerVariables("HTTP_REFERER") IsNot Nothing, ctx.Request.ServerVariables("HTTP_REFERER").ToString(), String.Empty)
Dim sForm As String = IIf(ctx.Request.Form IsNot Nothing, ctx.Request.Form.ToString(), String.Empty)
Dim sQuery As String = IIf(ctx.Request.QueryString IsNot Nothing, ctx.Request.QueryString.ToString(), String.Empty)
data = "SOURCE: " + ex.Source + vbCrLf
data += "MESSAGE: " + ex.Message + vbCrLf
data += "FORM: " + sForm + vbCrLf
data += "QUERYSTRING: " + sQuery + vbCrLf
data += "TARGETSITE: " + ex.TargetSite.ToString() + vbCrLf
data += "STACKTRACE: " + ex.StackTrace + vbCrLf
data += "REFERRER: " + referer
Dim eventLogName As String = "xyAMPLog"
Dim sourceName As String = "xyAMP"
Dim xyAMPLog As New EventLog()
xyAMPLog.Log = eventLogName
xyAMPLog.Source = sourceName
Try
xyAMPLog.WriteEntry(data, EventLogEntryType.Error)
Catch exc As Exception
Console.WriteLine(exc.Message)
End Try
'ctx.Server.ClearError()
End Sub
有什么建议可以清理吗?
谢谢,~ck 在圣地亚哥