【发布时间】:2016-12-28 11:57:31
【问题描述】:
我已成功读取服务器事件日志以显示来自应用程序事件日志的 SSIS 错误。目的是使第一线故障排除成为可能,而无需以管理员身份登录服务器。
我在 vb.net 中使用 EventLogEntry 来显示错误,其中源是 SQLISPackage110。然而让我感到困惑的是,当查看事件日志中的错误时,有一个“源名称”属性显示包名称。但是 EventLogEntry 似乎没有这个属性,这使得无法判断哪个包返回了错误。
有没有人遇到过这个并设法找到解决方法? 下面是错误的屏幕截图和我的一些 vb.net 代码
Dim myEventLogEntryCollection As EventLogEntryCollection = myEventLog1.Entries
myEventLog1.Close()
Dim x As Integer
Dim entry As EventLogEntry
If myEventLogEntryCollection.Count > 0 Then
strTable += "<table class='table table-bordered'><tr><th>Time Written</th><th>Source</th><th>Event type</th><th>Message</th></tr>"
For Each entry In myEventLogEntryCollection.Cast(Of EventLogEntry).Reverse 'cast and reverse to show newest first
If entry.Source = strEventSource And (entry.EntryType.ToString = "Error" Or entry.EntryType.ToString = "Warning") Then
strTable += "<tr>"
strTable += "<td>" + entry.TimeWritten.ToShortDateString + " " + entry.TimeWritten.ToShortTimeString + "</td>"
strTable += "<td>" + entry.Source.ToString + "</td>"
strTable += "<td>" + entry.EntryType.ToString + "</td>"
strTable += "<td>" + entry.Message + "</td>"
strTable += "</tr>"
x += 1
End If
If x > 100 Then Exit For 'could be 1000s in the log
Next
strTable += "</table>"
End If
【问题讨论】: