Using Serilog with ASP.NET Core 2.0

In case you’re unfamiliar, Serilog is a an open source event library for .NET. Conceptually, Serilog gives you two important components: loggers and sinks (outputs). Most applications will have a single static logger and several sinks, so in this example I’ll use two: the console and a rolling file sink. Starting with a new ASP.NET Core 2.0 Web Application running on .NET Framework (as in the image to the right), begin by grabbing a few packages off NuGet: Serilog Serilog.AspNetCore Serilog.Settings.Configuration Serilog.Sinks.Console Serilog.Sinks.RollingFile Next, you will need to modify some files. Startup.cs Startup constructor Create the static Log.Logger by reading…