What is the best way to write event log entries?

后端 未结 6 1186
盖世英雄少女心
盖世英雄少女心 2020-12-08 08:35

I recently had a problem during the deployment of a windows service. Four computers did not cause any problems, but on the fifth any attempt to start the service failed due

6条回答
  •  半阙折子戏
    2020-12-08 08:52

    Let's take a step back here:

    The system event log is there to alert the system administrator that there was a problem with something on the system. You should allow the service start to fail. This will show up in the system error log with a reported source of "Service Control Manager". This means that the sys admin will know about the failure.

    Next, if you need to troubleshoot then you should log exceptions to a file on disk at the top level of your program. You should also rethrow them so that the service start fails.

    You can then identify any problems in the system event logs and cross reference the time of the failure into your application logs.

提交回复
热议问题