本文整理汇总了VB.NET中System.Diagnostics.EventLogEntry.Source属性的典型用法代码示例。如果您正苦于以下问题:VB.NET EventLogEntry.Source属性的具体用法?VB.NET EventLogEntry.Source怎么用?VB.NET EventLogEntry.Source使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类System.Diagnostics.EventLogEntry 的用法示例。
在下文中一共展示了EventLogEntry.Source属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。
示例1: MyEventlogClass
' 导入命名空间
Imports System.Diagnostics
Class MyEventlogClass
Public Shared Sub Main()
Dim myEventType As String = Nothing
' Associate the instance of 'EventLog' with local System Log.
Dim myEventLog As New EventLog("System", ".")
Console.WriteLine("1:Error")
Console.WriteLine("2:Information")
Console.WriteLine("3:Warning")
Console.WriteLine("Select the Event Type")
Dim myOption As Integer = Convert.ToInt32(Console.ReadLine())
Select Case myOption
Case 1
myEventType = "Error"
Case 2
myEventType = "Information"
Case 3
myEventType = "Warning"
Case Else
End Select
Dim myLogEntryCollection As EventLogEntryCollection = myEventLog.Entries
Dim myCount As Integer = myLogEntryCollection.Count
' Iterate through all 'EventLogEntry' instances in 'EventLog'.
Dim i As Integer
For i = myCount - 1 To 0 Step -1
Dim myLogEntry As EventLogEntry = myLogEntryCollection(i)
' Select the entry having desired EventType.
If myLogEntry.EntryType.ToString().Equals(myEventType) Then
' Display Source of the event.
Console.WriteLine(myLogEntry.Source + " was the source of last "& _
"event of type " & myLogEntry.EntryType.ToString())
Return
End If
Next
End Sub
End Class
开发者ID:VB.NET开发者,项目名称:System.Diagnostics,代码行数:39,代码来源:EventLogEntry.Source
示例2: Module1
' 导入命名空间
Imports System.Diagnostics
Module Module1
Sub Main()
Dim Log As New EventLog("Application")
Dim Evt As EventLogEntry
For Each Evt In Log.Entries
Console.WriteLine(Evt.Message)
Console.WriteLine(Evt.TimeGenerated)
Console.WriteLine(Evt.Source)
Next
End Sub
End Module
开发者ID:VB程序员,项目名称:System.Diagnostics,代码行数:17,代码来源:EventLogEntry.Source
注:本文中的System.Diagnostics.EventLogEntry.Source属性示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论