Serilog has been ticking along since our 1.0 release six weeks ago. We’ve added a few new faces to our Contributors page since then, including
- an email sink from Andrew McClenaghan,
- a Splunk sink from Matthew Erbs, and
- improvements to the Azure Table Storage sink from Chad Tolkien.
We’ve had plenty of help keeping the project healthy with smaller pull requests, discussions and issue reports.
The current version on NuGet, now stamped ’1.1′, rolls up a few things that are worth a brief mention here too:
.NET 4.0 support
In case you missed the somewhat understated mention on Twitter, the Serilog package now adds support for .NET 4.0. This includes the logging pipeline and all of the built-in sinks (file, console, …). As of writing, some binary compatibility constraints mean that most of the “Extras” and add-on sinks will need to be modified or recompiled to use on .NET 4.0, so drop a line to the mailing list if there’s anything particular you need help with.
To get going with Serilog on .NET 4 all you need to run is:
Improved byte[] handling
In Serilog 1.0, byte arrays are treated as scalar values. This is because many data stores have built-in support for simple binary values.
Log.Information("Received {Packet}", packet);
This code would result in the contents of packet
being passed through and serialized by any configured sinks that supported it (e.g. any of the JSON-based sinks).
Two problems came out of this:
- Big binaries could cause a nasty payload surprise
- Serilog’s asynchronous logging pipeline requires that scalar values are immutable, which byte arrays aren’t
1.1 makes a different set of compromises that will be a bit more friendly.
Byte arrays smaller than a kilobyte will continue to be passed through as scalar values, but internally we make a copy at the time of logging to protect from later mutations. There are a few use cases where small chunks of binary data are useful in logs – hopefully less than 1 kb is about the sweet spot for those.
Byte arrays larger than 1 kilobyte are now passed through the pipeline as descriptive strings, including the first 16 bytes in hex and the overall length. A large binary will look like:
Much more fun than 4 GB of base-64 encoded text in JSON. It is still possible to serialize arbitrarily-large binaries with Serilog using a custom type and destructuring policy. If you’re interested in doing this please mail the discussion list.
As part of this refresh, handling of Nullable
s and Delegate
s were also improved.
Diagnostic help
One tiny but crucial improvement, the Serilog package now includes PDBs for the Serilog.dll
and Serilog.FullNetFx.dll
binaries, increasing our chances of getting meaningful stack traces in error reports.
Along with this the SelfLog
class, used for debugging Serilog itself, now flushes its output after writes making use with file streams easier.
That’s it for today, happy (Seri-)logging