NLog is an open source and lightweight logging platform with rich log routing and management capabilities. NLog is also easy to configure and extend. I’ve discussed using NLog in .Net and using NLog in ASP.Net Core in earlier posts. In this article, I will discuss how we can perform more advanced operations using NLog.
Specifically, we will look at how to configure NLog using a .config file as well as code-based configuration, how to automatically rotate logs, how to use a database as a log target, and how to improve performance by logging data asynchronously. I will also share some best practices for using NLog.
Create an ASP.Net Core MVC project in Visual Studio
First off, let’s create an ASP.Net Core project in Visual Studio 2019. Assuming Visual Studio 2019 is installed in your system, follow the steps outlined below to create a new ASP.Net Core MVC project in Visual Studio.