Event Log: create event source and display : Event Log « Windows System « VB.Net






Event Log: create event source and display

Event Log: create event source and display
 
Imports System
Imports System.Data
Imports System.Windows.Forms
Imports System.Drawing
Imports  System.Diagnostics 
Public Class MainClass
    
    Shared Sub Main()
       Dim logStatus As System.Diagnostics.EventLog
       logStatus = New System.Diagnostics.EventLog
        If Not EventLog.SourceExists("StatusSource") Then
            EventLog.CreateEventSource("StatusSource", "StatusLog")
            Console.WriteLine("Creating event source")
        End If

        ' Set the EventLog component's source.
        logStatus.Source = "StatusSource"

        ' Write a Starting message to the log.
        logStatus.WriteEntry(Now & "> " & "Starting", _
            EventLogEntryType.Information)


        For Each log_entry As EventLogEntry In logStatus.Entries
            Console.WriteLine(log_entry.Message)
        Next log_entry

    End Sub
End Class

           
         
  








Related examples in the same category

1.Event Log