How to use log4net with Dependency Injection

前端 未结 4 1879
死守一世寂寞
死守一世寂寞 2020-12-04 09:16

I\'m trying to figure out what the right patter and usage of log4net is with a dependency injection framework.

Log4Net uses the ILog interface but requires me to ca

4条回答
  •  鱼传尺愫
    2020-12-04 09:54

    If you are really concerned about having multiple loggers, you can always declare a global logger and call that for all your logging needs. The downside to this is that you lose the built in ability to identify the class that the log was issued from, but you can also inject your own custom message into the log to identify the class.

    It depends on how robust you want the logging to be. You can also simply put the logger at the main class and let all unhandled exceptions bubble up to it for logging.

提交回复
热议问题