Is there a logging facade for the .NET world?

2019-01-31 16:06发布

I'm somewhat new to the .NET stack and I was wondering if there is an equivalent to slf4j for the .NET platform. For me, logging to a Facade and being able to swap out logging implementations as needed just makes sense. Furthermore, the wrapper APIs available in slf4j have saved me many times when I needed to use a third-party library that was coded against a single logging framework that I wasn't using.

Is there a project out there that acts as a facade between loggers like log4net, nLog and Enterprise Library? Are there wrappers that allow me to shortcut calls to those libraries and direct them to another library? Should I start out an open source project to do this myself? Is this question a duplicate because I don't know the right way to ask? Conversely, is the common way to do this using aspect orient programming?

7条回答
神经病院院长
2楼-- · 2019-01-31 16:32

I had the same Problem. After going through those recommended above, I discovered Ninject.Extensions.Logging

Which is great since a facade makes best sense in combination with DI anyway

It comes with proxies for NLog, NLog2 & log4net.

Here is a nice example on how to use it in combination with NLog: http://blog.tonysneed.com/2011/10/09/using-nlog-with-dependency-injection/

I understand, that this question is already a couple of years old, but due to completeness for other users, I still chose to post this 'Solution'

查看更多
登录 后发表回答