Is passive logging possible in .NET?

前端 未结 6 434
北海茫月
北海茫月 2021-02-02 03:19

I\'m frequently frustrated by the amount of logging I have to include in my code and it leads me to wonder if there\'s a better way of doing things.

I don\'t know if thi

6条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-02 03:48

    I use the opensource Apache log4net in all of my projects. It's a very simple implementation with all kinds of extensions that allow you to log to databases, zip files, rolling log files, RRS feeds, telnet clients, etc. Logging is basically as simple as:

    'Will print stack trace after message'
    log.err(ex.message,ex)
    
    log.warn("warn")
    log.info("info")
    log.debug("debug")
    

    Logging parameters such as the output format and log level to output are all read real time while your app is in runtime.

提交回复
热议问题