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?
Update for .NET Core:
I'm incorporating Simple Logging Facade because it appears to support The Object Guy's Logging Framework for .Net out of the box.
I somehow found all solutions in here unsatisfying, especially for libraries/APIs. Although I never thought I would, I actually wrote an Open Source "logger" which should handle most concerns.
Maybe you can have a look at Dapplo.Log, you can get it from NuGet.
The idea is to use Dapplo.Log in your library, and the project which uses this can than direct (when needed) any log output to their logger of choice. Examples for directing the output can be found in the tests, with implementations of some major frameworks here.
It's probably not perfect (yet), and I welcome pull-requests or tickets.
Since this was written another interesting logging wrapper called Fody.Anotar has appeared. As of today, it's probably the most complete of all of them. Most of the other, but Logging Faciliy, are quite outdated, supporting only the oldest loggers.
It has adapters for NLog, Log4Net, Serilog, CommongLogging, Catel, LibLog, MetroLog, NServiceBus and Splat, and allows you to create an adapter for your own library.
You can use Nuget to install it. Look for Anotar.*.Fody packages, for example Anotar.NLog.Fody.
Excuse I used this thing and I forgot it wasn't the Apache version. It's actually open-source and part of a project called common infrastructure. It is also called common logging. It works with MS Enterprise, log4net and others. It works well.
Take a look at Castle Windsor Logging Facility.
Base code is here. Log4net adapter here. NLog adapter here.
Added adapter for Serilog.
Without the adapters there is suppor for ConsoleLogger, DiagnosticsLogger, StreamLogger and NullLogger.
It's pretty easy to write adapters to any other logging framework.