The issue is that when host machine is restarted (Windows restart) or shutdown (Windows shutdown) nothing is being written to the log.
I have the following in a Windows Service:
protected override void OnStart(string[] args)
{
eventLogUtility.WriteToEventLog("Service has Started.", EventLogEntryType.Information);
}
protected override void OnStop()
{
eventLogUtility.WriteToEventLog("Service has Stopped.", EventLogEntryType.Information);
}
/// <summary>When implemented in a derived class, executes when the system is shutting down.
/// Specifies what should occur immediately prior to the system shutting down.</summary>
protected override void OnShutdown()
{
eventLogUtility.WriteToEventLog("Service has Shutdown.", EventLogEntryType.Information);
}
When the service starts, "Service has Started." is written to the log.
When the service is stopped by me, "Service has Stopped." is written to the log.
P.S. Using .Net 4.5