Our great sponsors
-
serilog-settings-configuration
A Serilog configuration provider that reads from Microsoft.Extensions.Configuration
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
Why Serilog? It is easy to set up, has a clean API, and is portable between recent .NET platforms. The big difference between Serilog and the other frameworks is that it is designed to do structured logging out of the box. Another thing I really like about Serilog is that it can be configured via the appsetting.json file alongside configuring through code. Changing logging configuration without touching the codebase is really helpful, especially in the production environment.
Serilog.AspNetCore nuget package has dependency on Serilog.Settings.Configuration nuget package and it is a Serilog settings provider that reads from Microsoft.Extensions.Configuration sources. The above configuration is equivalent to this:
To see complete SQL Server sink JSON configuration check out this.
If you're using SQL Server, PostgreSQL or MongoDB sinks, I have developed a small log viewer for small projects. It helps a lot, especially in the production environment and you don't need to query the database to view logs.
Source code for this walkthrough could found on the Github.