I have a diagnostic version of a service that logs as much as possible in the OnStart() and OnStop() methods.
One event that I am unable to capture is when the computer is physically restarted. My logging function usually records its output to a table in a database, but when that is not available it posts to the EventLog.
On a reboot my service neither logs to the table nor to the EventLog.
It makes sense to me that I would not be able to post to the table, since SQL Server is in the process of shutting down, but it also seems that due to a timing issue the EventLog may also be shutting before the service can default to write there.
In the case of a shutdown, MSSQLSERVER reports an information message in the EventLog:
SQL Server is terminating because of a system shutdown. This is an informational message only. No user action is required.
Is there a way to do something similar for my service?