jmsjms
asked on
Writing to the Event Log vb net
Hi, I'm trying to write to the event log in a Windows Service Application I'm developing.
The Service builds OK. But the service just stops as soon as it starts without any logging.
Any idea?
If Not System.Diagnostics.EventLo g.SourceEx ists("MySe rvice") Then
System.Diagnostics.EventLo g.CreateEv entSource( "NyService ", "MyService Log")
End If
_eventLog = New EventLog()
_eventLog.Source = "MyService"
_eventLog.WriteEntry(" Service started.", EventLogEntryType.Informat ion)
The Service builds OK. But the service just stops as soon as it starts without any logging.
Any idea?
If Not System.Diagnostics.EventLo
System.Diagnostics.EventLo
End If
_eventLog = New EventLog()
_eventLog.Source = "MyService"
_eventLog.WriteEntry(" Service started.", EventLogEntryType.Informat
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sounds good! Can this be done with the LE version of install shield?
Not sure. You can create another exe which you can ask user to launch as admin when you find out, in your main program, that event source does not exist.
ASKER
But you cant have any user-interaction with a service so how could you do this?
There are work arounds but i think first thing to do is to determine if installshield LE can help you.
ASKER
I've run out of time to devote to this, so cant confirm whether installsheild LE can help here of not.
I'll mark this as an answer so people can see what I found out and one possible way forward.
I'll mark this as an answer so people can see what I found out and one possible way forward.
ASKER
My comment indicates that just getting a service to create the event log source will not work (despite some examples on the web) UNLESS the service has admin rights.
Codecruisers suggestion that it's done as part of the installation is a good idea but I can't confirm this works yet.
Codecruisers suggestion that it's done as part of the installation is a good idea but I can't confirm this works yet.
do u have exception handling on your code to detect errors?
you can also use Debugger.Break() inside the class in order to debug the code when the service starts.