Logging in ASP.NET Core
Sometimes we assume an ideal world where our backend application runs successfully. However, in the real world, there are always events or errors to be expected. For instance, our connection to SQL Server may drop for whatever reason. To do our part, as a best practice, we should expect errors and handle them properly.
Logging is where you print lines of output as your application runs that give you some info about the usage, performance, errors, and diagnostics of your application. In short, the output tells us the story of what is going on internally in the application.
So how do we do this in ASP.NET Core?
Logging in ASP.NET Core
If you have ever done any work with ASP.NET Core, you have probably seen the ILogger
interface. Perhaps, you even know that ASP.NET Core has logging built in by default. But do you know that we can configure it or replace it? Yes, we can use third-party libraries such as Serilog
or NLog
, which you will see shortly. But...