What is the best way to write event log entries?

后端 未结 6 1176
盖世英雄少女心
盖世英雄少女心 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 09:03

    I think logging exceptions is one of the rare cases where you are better off swallowing the exception. In most cases you don't want your app to fail on this.

    But why are you writing your logging code yourself anyway? Use a framework like NLog or Log4Net! These also swallow exceptions like I just said but you can redirect the logging output to a different location (file, messagebox etc.) with just a configuration change. This makes solving problems like this much easier.

提交回复
热议问题