Would you like to try Serilog, but have existing log4net infrastructure? On the journey to “1.0” Serilog needs your experiences and feedback. The Serilog.Sinks.Log4Net package may provide just what you need to kick the tyres of Serilog without turning your existing code and libraries upside-down.

This package lets you pipe structured log events off to suitable storage, while text representations are merged into log4net to be written to a consolidated flat log file.


To install the package:

PM> Install-Package Serilog.Sinks.Log4Net

Your existing log4net configuration remains unchanged, e.g. using the XmlConfigurator:


In your Serilog configuration, include both your choice of structured event storage (in this example the RavenDB sink), and the log4net sink:

Log.Logger = new LoggerConfiguration()

Events written to a log4net logger will travel through the log4net pipeline only. Events written to Serilog will be emitted to RavenDB with full property structure intact, and to the log4net pipeline as regular text-based messages.

The sink is very simple, preserving log levels (Information, Warning, Error and so on) as well as the source class name if ForContext<TSource>() is used.

A running example can be found in the Serilog GitHub repo.