Serilog is an open-source logging framework for .NET that seamlessly integrates text-based logging and fully-structured events. You can write events to regular text files, or use Serilog in combination with a structured log server for the easiest log filtering and navigation on the planet!
TL;DR we’ve been busy - Serilog 1.5 is out with new external configuration support; the project has been reorganized; and if you’re in Portland next week you can learn more about Serilog at .NET/FRINGE/.
First up: 1.5 is live!
Serilog 1.4 has been a long-lived and stable release. In fact, well over half of Serilog’s 69,304 downloads have been of the 1.4 series!
What’s new? Core support for external configuration sources.
The feature responsible for a minor-version bump is integrated “external settings” support.
Serilog was, is, and always will remain a primarily code-driven library. For a long while however the project offered a simple ``-based configuration option that could be used to specify the minimum logging level, enriching properties, and sink parameters in XML
We found this package, Serilog.Extras.AppSettings, popular and useful enough in practice that some support for this functionality in the core is warranted.
If you install the Serilog package into a .NET project with XML configuration support, you can now use the
.ReadFrom.AppSettings() method to pull logger configuration directly from an XML configuration file:
var log = new LoggerConfiguration() .ReadFrom.AppSettings() .WriteTo.ColoredConsole() .CreateLogger();
XML configuration is very simple and relies on the `` element found in standard config files:
<?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="serilog:minimum-level" value="Debug" /> <add key="serilog:write-to:File.path" value="C:ProgramDataMyAppmy-log.txt" /> <add key="serilog:enrich:with-property:MachineName" value="%COMPUTERNAME%" /> </appSettings> </configuration>
But, we haven’t simply shoehorned the old “extras” package into the core. Serilog’s new configuration support is open and will be fitted to the new ASP.NET 5 configuration system when it’s finalized. There’s already a simple key-value pair setting implementation,
.ReadFrom.KeyValuePairs(), that you may find useful if XML isn’t your style.
You can read more about using this feature in the documentation.
New Community Projects
Though the split has been in progress for some time, 1.5 marks the end of a big push from Serilog’s core contributors to break out many of the useful “extras” projects into their own top-level organisations and repositories.
Michiel van Oudheusden led the charge with SerilogMetrics, a Metrics.NET-inspired project that adds timer, gauge, and counter features on top of Serilog. This replaces the original Serilog.Extras.Timing package.
Destructurama! makes Serilog able to accurately serialize exotic things like F# discriminated unions, or JSON.NET dynamic objects. These packages replace their earlier versions that were contributed and baked as “extras”.
Finally, consistent support for logging web application requests is the goal of the SerilogWeb project. Currently the ASP.NET and OWIN support libraries have moved over, and I have high hopes for these finding some interesting synergy with an ASP.NET 5 integration there when the time comes.
If you’re building something that adds to Serilog, let us know – we’d love to list you on the community projects wiki page we’re maintaining for this purpose.
The Great Sink Split
We’ve bunkered down to make sure Serilog “the project” stays lean and healthy. It’s easy for open source projects that integrate with many technologies to grow and sprawl, and as it evolved Serilog hit nearly fifty interrelated projects in its core solution.
Starting from Serilog 1.5, all of the various provided sinks live in standalone GitHub repositories. Hat tip to Matthew Erbs for helping push this huge task to completion! Combined with the move to establish our new community projects, this brings the Serilog solution itself back to a pair of projects – the portable core, and additional full .NET framework support.
The 1.x series of releases is slowing down, but we’re making sure that we have the right project structure for Serilog to stay fresh and current well into the future.
Who contributed to this release?
We now count 57 individuals on our contributors page. This number isn’t an accurate representation any longer since new (sink) code now lives outside the Serilog repository, so there are even more wonderful folk not listed here.
The conference is about breaking the rules and pushing the boundaries of .NET, so I’m especially excited to hear Daniel will be presenting Serilog there.
Serilog 1.5 is now on NuGet, go get it!