- We already have some familiarity with C#, .NET Core and Logging.
- We created a fresh web application in .NET Core and wanted to understand how Logging is already configured in the template code.
- We have only 3 hours to understand Logging so that we can customize the logging behavior for our Project.
First 2 hours
Rather than jumping into the docs upfront it’s always awesome to get a technical walkthrough of the whole topic through a video. Let’s go through this 1 hour video and simultaneously try the examples on our machine. Take 1 more hour to fiddle with the code to understand the overridden APIs.
Next 1 Hour
Now let’s go through the official Microsoft documentation for Logging in .NET Core. Naturally, after going through the video, documentation will feel more comprehensive and by covering the topics there we’ll make sure that nothing is missed.
- We now understand the in-built Logging providers like Console and Debug.
- We also understand ILogger interface, ILoggerFactory, categories and default Log-Levels.
- We can configure Logging behavior through appsettings.json file or command line arguments.
Moving forward, we can improve our logging based on the complexity of our project and logging requirements by knowing few more things.
- Understanding Log-scopes by enabling the IncludeScopes property as true.
- Understanding Log filter rules.
- Using third-party logging packages like NLog, Serilog etc.
- Writing logs to cloud based monitoring services like Azure Application Insights.