I have a diagnostic version of the service that logs as many as possible in the OnStart () and OnStop () methods.
One event that I cannot perform is when the computer is physically restarted. My logging function usually writes its output to a table in the database, but when it is not available, it is sent to EventLog.
When I restart, my service is not registered either in the table or in the EventLog.
It seems to me that I will not be able to send a message to the table, since SQL Server is in the process of shutting down, but it also seems that due to a synchronization problem, EventLog can also be closed before the service can write there by default.
In case of shutdown, MSSQLSERVER reports an informational message in EventLog:
SQL Server shuts down due to system shutdown. This is an informational message. No user action required.
Is there a way to do something like this for my service?
source share