Logging is an essential feature for detecting and investigating issues in our applications. Logging frameworks make it easy to log event data to pre-configured log targets. However, if your log file contains unstructured data, it becomes a nightmare to query the data. This is where structured logging comes into play.
Structured logging makes it easy to query event data by ensuring that the data to be logged is written in a structured format. The format could be XML, JSON, or any other structured format that makes parsing the data easy. Structured logging also helps in processing the log files for log analytics.
Serilog is a third-party, open-source library for structured logging. It allows developers to easily log structured event data to the console, to files, and to all kinds of storage systems. This article presents a discussion of how we can work with Serilog in ASP.Net Core.
Create an ASP.Net Core project in Visual Studio
In this section we will create an ASP.Net Core application and use it to learn how we can work with Serilog. Follow the steps outlined below to create a new ASP.Net Core project in Visual Studio 2017.