Error logging in C#

前端 未结 15 1785
一个人的身影
一个人的身影 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:46

    Log4Net, as others have said, is fairly common and similar to Log4j which will help you if you ever do any Java.

    You also have the option of using the Logging Application Block http://www.codeproject.com/KB/architecture/GetStartedLoggingBlock.aspx

    0 讨论(0)
  • 2020-12-04 06:47

    I would highly recommend looking at log4Net. This post covers the majority of what you need to get started.

    0 讨论(0)
  • 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);
    
    0 讨论(0)
提交回复
热议问题