Serilog is one of the most popular logging libraries. This tutorial will show you how to set it up for an AspNetCore project.
Serilog.AspNetCore
Install Nuget Package Serilog.AspNetCore. It is the recommended nuget package to configure Serilog for AspNetCore projects.
Add JSON Configuration
This sample configuration asks Serilog to use file logging. To learn more about Serilog configuration, please read this doc. For json configuration syntax, please refer to Serilog.Settings.Configuration. You can find a more advanced sample here.
This is suggested in the document. Although it offers some benefits, it also causes the unhandled exceptions being logged twice. Until it is fixed, I don’t suggest using it.