Logging with Serilog
Although .NET includes logging frameworks, third-party logging providers give more power and flexibility by using structured event data. Serilog is the most popular.
Structured event data
Most systems write plain text messages to their logs.
Serilog can be told to write serialized structured data to the log. The @
symbol prefixing a parameter tells Serilog to serialize the object passed in, instead of just the result of calling the ToString
method.
Later, that complex object can be queried for improved search and sort capabilities in the logs.
For example:
var lineitem = new { ProductId = 11, UnitPrice = 25.49, Quantity = 3 };
log.Information("Added {@LineItem} to shopping cart.", lineitem);
You can learn more about how Serilog handles structured data at the following link: https://github.com/serilog/serilog/wiki/Structured-Data.
Serilog sinks
All logging systems need to record the log entries somewhere...