I would like to create an EventLog for my application, let's call it "myApp Log". I then want to include a source which will be different depending on my service name. For instance, I have two services (serviceA and serviceB). When the service starts I check to see if the EventLog.Source is created before I try writing to it.
I do that by:
If it doesn't exist, and there will be times where it wont exist based on the user installing the service and the name they provide at install time or in the app.config files, then I have to create it. The issue is that when I create it, it doesn't register the source to "myApp Log" instead it registers it to the "Applications Log."
The PC, where the service remains, must be restarted so that the source will be mapped to the correct Event Log. How can I do this without requiring the reboot?
I do that by:
vb.NET Code:
If Not System.Diagnostics.EventLog.SourceExists(svcName) Then System.Diagnostics.EventLog.CreateEventSource(svcName, "myApp Log") End If
If it doesn't exist, and there will be times where it wont exist based on the user installing the service and the name they provide at install time or in the app.config files, then I have to create it. The issue is that when I create it, it doesn't register the source to "myApp Log" instead it registers it to the "Applications Log."
The PC, where the service remains, must be restarted so that the source will be mapped to the correct Event Log. How can I do this without requiring the reboot?