Serilog has been rocking along these last couple of months. Just to keep everyone in the loop, this post is a very brief roll-up of progress that the project has made recently.

Serilog.Sinks.Async 1.0 — most Serilog sinks by default write events in batches, asynchronously, to reduce application latency and improve network performance; a few do not, notably the Console and File/RollingFile sinks. For these cases, Serilog.Sinks.Async provides WriteTo.Async(). This wrapper moves logging onto a worker thread, so that application code can continue executing while file writes etc. proceed in the background.

Log.Logger = new LoggerConfiguration()
    .WriteTo.Async(w => w.RollingFile("logs/app-{Date}.txt"))
    .CreateLogger();

Audit logging — Serilog 2.2 added reliable logging (auditing) via the AuditTo configuration option alongside WriteTo. Currently available through the File and Seq sinks, reliable logging ensures the event is written before logging continues, and propagates exceptions back to the caller if logging cannot proceed.

Log.Logger = new LoggerConfiguration()
    .AuditTo.File("logs/app.txt")
    .CreateLogger();

Periodic flush-to-disk — the File and RollingFile sinks now accept a flushToDiskInterval: option; when specified, the sink will periodically request that the operating system flush any intermediate buffers to the storage device:

Log.Logger = new LoggerConfiguration()
    .WriteTo.File("logs/app.txt", flushToDiskInterval: TimeSpan.FromSeconds(2))
    .CreateLogger();

(Some log collectors, it turns out, won’t pick up file changes until they hit disk. This feature was added to support the Azure AppServices diagnostics logger, which is built on top of Serilog.)

Compact JSON reader — the deserializer I wrote about recently has now been moved into the Serilog organization, where we hope to extend and support it in lockstep with the formatter that it compliments.

XML/JSON configuration generator — the amazing Serilog Analyzer from Robin Sue has been extended to generate app.config or appsettings.json entries from Serilog’s code-as-configuration DSL:

Serilog Analyzer in action

Fundamentals — a string of PRs from Sergey Komisarchik have been pushing forward fundamentals, like MessageTemplateCache concurrency and PeriodicBatchingSink queue bounds. Additional payload limiting controls, such as string length limits are coming along on dev thanks to Artur Krajewski.

.NET Core sink support — the ongoing work to support Serilog’s many sinks on .NET Core is nearing completion, with practically all of the widely-used sinks now across (thanks, everyone!). The SMTP email sink just got pre-release support for .NET Core via MailKit, courtesy of Adam Chester.

One notable exception is the SQL Server sink, which is waiting for some System.Data APIs we won’t see until .NET Standard 2.0. In the meantime, Colin Young has been forging ahead and improving this sink with PRs increasing test coverage, enabling trigger support, and rounding out schema customization options.

Roll on hour/half-hour — in addition to {Date}, the RollingFile sink now supports rolling on {Hour} or {HalfHour} thanks to this PR from Jose at XML Travelgate:

Log.Logger = new LoggerConfiguration()
    .WriteTo.RollingFile("logs/app-{Hour}.txt")
    .CreateLogger();

I’m sure there’s plenty that I’ve missed; if you’re working on something Serilog-related please feel free to jump in on the comments.