To write an entry to System Log, you could do it 2 ways:
To write to existing source, use:
EventLog.WriteEntry("TestApp", "This is Test") -- This will write log under Application with source name as TestApp.
To write to new source, use:
Dim objEventLog As New System.Diagnostics.EventLog()
Dim AppName As String = "Test App"
Dim LogName As String = "My Log"
'Register the App as an Event Source
If Not System.Diagnostics.EventLog.SourceExists(AppName) Then
System.Diagnostics.EventLog.CreateEventSource(AppName, LogName)
End If
objEventLog.Source = LogName
objEventLog.WriteEntry("This is Test")
HTH.
- Use existing source "Application" in the Event Viewer
- Create new source just for your application
To write to existing source, use:
EventLog.WriteEntry("TestApp", "This is Test") -- This will write log under Application with source name as TestApp.
To write to new source, use:
Dim objEventLog As New System.Diagnostics.EventLog()
Dim AppName As String = "Test App"
Dim LogName As String = "My Log"
'Register the App as an Event Source
If Not System.Diagnostics.EventLog.SourceExists(AppName) Then
System.Diagnostics.EventLog.CreateEventSource(AppName, LogName)
End If
objEventLog.Source = LogName
objEventLog.WriteEntry("This is Test")
HTH.