I have a Windows Service. I'm struggling to get an EventLog working properly.
In the Windows Service's constructor I do:
public MyService()
{
InitializeComponent();
AutoLog = false;
if (!EventLog.SourceExists(ServiceName))
{
EventSourceCreationData creationData = new EventSourceCreationData(ServiceName, ServiceName);
EventLog.CreateEventSource(creationData);
}
}
After I run the service, I get no exceptions, but I can't see anything under Application and Services Logs in Event Viewer! (even after computer reset).
I checked my registry and my service appears in
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\MyService
not here:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\eventlog\MyService
I install Windows Service via Visual Studio's Developer Command Prompt for VS2015 opened as Administrator.
Why there? why not in eventlog? Why I can't see it in Event Viewer?
Thanks!