NLog with ILogger in .Net 6.0 Web API

There are several .Net things that are essential, but, they keep flying under the radar. One of those things is logging.

A few years ago, I was working for a real estate company in UK, remotely from India, of course. We had issues with figuring out where int he 250 step process was a simple process crashing. I had to spend hours and hours debugging the thing. Then, I ended up building a simple logging library of my own. and, we started tracking the issues much faster.

The code is here.

CSharpForStudents/WebApiDotNet6/LoggingDotNet6 at main · Jay-study-nildana/CSharpForStudents

Why NLog?

My lifelong policy is do more with the absolute minimum. I chose NLog because the library has fantastic documentation. It took me only a few minutes to understand how to get the library working with .Net Web API. As a bonus, the documentation was updated to .Net 6.0.

Further, Remember Microsoft already has the excellent ILogger interface. The whole point of using a provider such as NLog, is so that, you can do extra things, like writing to files.

Microsoft does not provide any providers that write to file. However, they do have providers that write to Azure services.