Appsettings.json logging: Enable and set LogLevel variables for ILogger

Опубликовано: 31 Декабрь 2024
на канале: Round The Code
3,817
32

Logging can be set up and enabled in the appsettings.json for a .NET application.

The minimum LogLevel can be set which is used for ILogger in an ASP.NET Core project. As the ILogger is added to the IoC container as part of dependency injection, it can be used in different parts of the applications.

We'll show you what the log levels are, and how to set up a different minimum log levels for different namespaces.

Logging is supported across many different types of .NET C# platforms, including .NET Core and .NET 6. It is also included in many different project types, like a web application, console application and a class library.

Our main focus is on an ASP.NET Core web app, but the same practices can be used across different types of projects.

This is part 4 of our appsettings.json course. The full playlist is here:
   • AppSettings.json course  

💻 Download the code example for this demo 💻
https://www.roundthecode.com/dotnet-c...

📖 Learn .NET and C# with our online courses 📖
https://www.roundthecode.com/dotnet-c...

► Chapters
0:00 How ILogger can be used in appsettings.json
0:24 Learn .NET with our online courses
0:34 Log levels available for logging in ASP.NET Core
1:10 How logging can be configured in appsettings.json
1:56 Write a log in an ASP.NET Core Web API
3:15 Write a log with a deeper namespace
4:40 How logging works in environments

#appsettings #ilogger #logging