Simple way to perform error logging?

后端 未结 9 1667
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-30 03:52

I\'ve created a small C# winforms application, as an added feature I was considering adding some form of error logging into it. Anyone have any suggestions for good ways to go a

9条回答
  •  我在风中等你
    2021-01-30 04:51

    After reading the suggestions here, I ended up using the following:

    private void LogSystemError(string message)
    {
        EventLog.WriteEntry("YourAppName", message, EventLogEntryType.Error);
    }
    

    The EventLog class is available using System.Diagnostics.

    I avoided the options of logging into files (e.g. "yourLogFile.txt") to avoid issues of concurrency of multiple threads logging errors, location of the file and access security, and the possible issues of having a file that grows too large.

提交回复
热议问题