-
EventLog
Hi,
I am trying to create a class to write eventlogs on another computer.
It works fine when I don 't specify the log it needs to write in. Then the application will automatic take the "Application" log.
How can I create a new log on this other computer? (thru code!!!)
Thanks
Code:
Public Sub error2Log(ByRef errorEvent As Exception, ByVal location As String)
Dim log As New EventLog
Dim mess As String
log.MachineName = "B-MIS0-ROELANB"
log.Log = "myAppLOg" '<-- This does not work !!!
log.Source = Application.ExecutablePath
mess = vbNewLine & "TIME: " & Now & vbNewLine & vbNewLine
mess = mess & "DESCRIPTION: " & errorEvent.Message & vbNewLine & vbNewLine
mess = mess & "LOCATION: " & location & vbNewLine
log.WriteEntry(mess)
log = Nothing
End Sub
This is my Error:
An unhandled exception of type 'System.ArgumentException' occurred in system.dll
Additional information:
The source 'C:\projects\CemaPrep\CemaPrep\bin\CemaPrep.exe' is
not registered in log 'myAppLOg'. (It is registered in log 'Application'.)
" The Source and Log properties must be matched,
or you may set Log to the empty string,
and it will automatically be matched to th
-
I was creating my first service yesterday and ran into this problem also. But then I saw that every service on my machine writes to the Application log. They do not create their own event logs.
So I just went with the flow. If for example, SQL Server doesn't create it's own log, why would you?