Storing a structured log with Serilog
As we just discussed, tracking structured objects in the log helps us tremendously in understanding errors.
We, therefore, suggest one of the many logging frameworks: Serilog.
Serilog is a comprehensive library that has many sinks already written that allow you to store log data and search it later.
Serilog is a logging library that allows you to track information on multiple data sources. In Serilog, these sources are called sinks, and they allow you to write structured data inside the log applying a serialization of the data passed to the logging system.
Let’s see how to get started using Serilog for a minimal API application. Let’s install these NuGet packages. Our goal will be to track the same information we’ve been using so far, specifically Console
and ApplicationInsights
:
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.20.0" /> <PackageReference...