Questions tagged [slf4net]

slf4net - The Simple Logging Façade for .NET provides the means to easily plug in logging functionality into the applications.

SLF is a framework with a simple but ambitious mission: To provide every developer with the means to easily plug in logging functionality into her application. As such, it aims at two fundamental goals:

  • Simplicity: SLF allows you to plug in solid logging functionality into your application with literally one line of code, while providing you with an upgrade path to complex logging scenarios at any time.
  • Flexibility: SLF provides you with a common interface that decouples the logging framework of your choice from your code. This eliminates dependencies on a given framework, thus allowing you to switch (or even combine!) frameworks at any time. Furthermore, SLF’s modular architecture allows you to plug-in custom logging strategies very easily.

Basically, a façade just provides you with a common interface that decouples the used logging framework from your code:

//ILogger is the facade. Behind the scenes, a framework of your choice is used
ILogger logger = LoggerService.GetLogger();
logger.Info("hello world");

Features

  • Configurable through code or configuration files (app.config).
  • Support for named loggers with hierarchical fallback mechanisms.
  • Support for common logging frameworks such as log4net, NLog and EntLib out of the box.
  • Silverlight support.
  • Writing your own pluggable logging strategy is easy.
  • You can exchange the underlying logging mechanism at any time, even at runtime.
  • Extensible and modular architecture. Writing your own façade can be as simple as overriding one single method, but you can cover complex scenarios, should you have to.
  • Robust: In case of invalid configurations or logging instructions, SLF rather outputs debug warnings instead of crashing your application at runtime.
  • A ton of copy-and-paste ready samples for different use cases. .NET 2.0 compatible binaries.
4 questions
8
votes
2 answers

How can I resolve the correct logger type using AutoFac?

I'm updating a legacy project that uses AutoFac and I want to use NLog with Simple Logging Facade (SLF) I have used this in the past with Ninject and it's really easy to setup, I just have to do something like: kernel.Bind().ToMethod(x =>…
Jupaol
  • 21,107
  • 8
  • 68
  • 100
1
vote
1 answer

Log4Net Retrieve Appenders Programmatically

I have a separate Log4Net.config file with 2 appenders and 2 loggers, 1 logger for each appender. There is no logger. I am trying to add code to my application that will retrieve the filename for the logger to allow the user to view the…
Tim
  • 1,249
  • 5
  • 28
  • 54
0
votes
1 answer

How to access all entries in MDC dictionarry?

for the sake of having kind of the same setup in Java and C# (i know, terrible reason), I got this setup running in Java: log4j: ...
Johan P
  • 89
  • 13
0
votes
1 answer

No logging with configuration made in code using latest version of slf4net (1.0.0)

I'm using the slf4net.log4net nuget package to handle logging in a project. Because it must be possible for the loglevel to change at runtime, I made the configuration in code. The issue is that this code works fine in slf4net.log4net version…
Gert Hermans
  • 769
  • 1
  • 9
  • 30