Error logging in C#

前端 未结 15 1958
一个人的身影
一个人的身影 2020-12-04 06:11

I am making my switch from coding in C++ to C#. I need to replace my C++ error logging/reporting macro system with something similar in C#.

In my C++ source I can w

15条回答
  •  半阙折子戏
    2020-12-04 06:47

    Log4Net is a rather comprehensive logging framework that will allow you to log to different levels (Debug, Error, Fatal) and output these log statements to may different places (rolling file, web service, windows errors)

    I am able to easily log anywhere by creating an instance of the logger

    private static readonly ILog _log = LogManager.GetLogger(typeof([Class Name]));
    

    and then logging the error.

    _log.Error("Error messsage", ex);
    

提交回复
热议问题