Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
dTub
Скачать

ASP NET Core LogLevel configuration

Автор: kudvenkat

Загружено: 2019-05-31

Просмотров: 64054

Описание:

In this video we will discuss the significance of LogLevel configuration in ASP.NET Core.

Text version of the video
https://csharp-video-tutorials.blogsp...

Healthy diet is very important for both body and mind. We want to inspire you to cook and eat healthy. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking.
   / @aarvikitchen5572  

Slides
https://csharp-video-tutorials.blogsp...

ASP.NET Core Text Articles & Slides
https://csharp-video-tutorials.blogsp...

ASP.NET Core Tutorial
   • ASP.NET core tutorial for beginners  

Angular, JavaScript, jQuery, Dot Net & SQL Playlists
https://www.youtube.com/user/kudvenka...


LogLevel indicates the severity of the logged message. It can be any of the following. They are listed here from lowest to highest severity.
Trace = 0
Debug = 1
Information = 2
Warning = 3
Error = 4
Critical = 5
None = 6

LogLevel Enum

LogLevel enum is present in Microsoft.Extensions.Logging namespace

namespace Microsoft.Extensions.Logging
{
public enum LogLevel
{
Trace = 0,
Debug = 1,
Information = 2,
Warning = 3,
Error = 4,
Critical = 5,
None = 6
}
}

LogLevel in appsettings.json

LogLevel setting in appsettings.json file is used to control how much log data is logged or displayed.

"Logging": {
"LogLevel": {
"Default": "Trace",
"Microsoft": "Warning"
}
}

ILogger Methods

On the ILogger interface, we have log methods that include the log level in the method name. For example to log a TRACE message we use LogTrace() method. Similarly to log a WARNING message we use LogWarning() method. Notice, except for LogLevel = None, we have a corresponding method for every log level.

LogTrace()
LogDebug()
LogInformation()
LogWarning()
LogError()
LogCritical()

LogLevel Example

Consider the following Details() action in HomeController

public class HomeController : Controller
{
public ViewResult Details(int? id)
{
logger.LogTrace("Trace Log");
logger.LogDebug("Debug Log");
logger.LogInformation("Information Log");
logger.LogWarning("Warning Log");
logger.LogError("Error Log");
logger.LogCritical("Critical Log");

// Rest of the code
}
}

The following is the LogLevl configuration in appsettings.json file.

"Logging": {
"LogLevel": {
"Default": "Trace",
"Microsoft": "Warning"
}
}

The following Log output is displayed in the Debug Output window. Since we have set "Default": "Trace", we see everything from Trace level and higher. Since Trace is the lowest level we see all the logs.

EmployeeManagement.Controllers.HomeController:Trace: Trace Log
EmployeeManagement.Controllers.HomeController:Debug: Debug Log
EmployeeManagement.Controllers.HomeController:Information: Information Log
EmployeeManagement.Controllers.HomeController:Warning: Warning Log
EmployeeManagement.Controllers.HomeController:Error: Error Log
EmployeeManagement.Controllers.HomeController:Critical: Critical Log

However if you want WARNING and higher then set "Default": "Warning"

If you do not want anything logged set LogLevel to None. The integer value of LogLevel.None is 6, which is higher than all the other log levels. So nothing gets logged.

Log filtering in ASP.NET Core

Consider the following log statement

EmployeeManagement.Controllers.HomeController:Trace: My log message

EmployeeManagement.Controllers.HomeController is the LOG CATEGORY
Trace is the LOG LEVEL. Remeber log level can be (Trace, Debug, Information, etc...)

In simple terms, LOG CATEGORY is the fully qualified name of the class that logged the message. The log category is displayed as a string in the logged message so we can use it easily determine from which class the log came from. LOG CATEGORY is used to filter logs.

ASP NET Core LogLevel configuration

Поделиться в:

Доступные форматы для скачивания:

Скачать видео mp4

  • Информация по загрузке:

Скачать аудио mp3

Похожие видео

ASP NET Core Identity tutorial from scratch

ASP NET Core Identity tutorial from scratch

Чистая архитектура с ASP.NET Core 10

Чистая архитектура с ASP.NET Core 10

Repository pattern in asp net core

Repository pattern in asp net core

Global Exception Handling in Asp.Net Core Web API using IExceptionHandler

Global Exception Handling in Asp.Net Core Web API using IExceptionHandler

«НАЧНЕТСЯ КАСКАДНЫЙ ЭФФЕКТ». В России бьют тревогу. КРИЗИС УЖЕ НАЧАЛСЯ

«НАЧНЕТСЯ КАСКАДНЫЙ ЭФФЕКТ». В России бьют тревогу. КРИЗИС УЖЕ НАЧАЛСЯ

Расслабляющая музыка, чтобы снять стресс, беспокойство и депрессию • разум, тело #23

Расслабляющая музыка, чтобы снять стресс, беспокойство и депрессию • разум, тело #23

Обстрелы стирают Украину

Обстрелы стирают Украину

Немедленный приказ Зеленского / МИД бьёт тревогу

Немедленный приказ Зеленского / МИД бьёт тревогу

⚡️ Трампа встретили матом || Дерзкое заявление Зеленского

⚡️ Трампа встретили матом || Дерзкое заявление Зеленского

Для Чего РЕАЛЬНО Нужен был ГОРБ Boeing 747?

Для Чего РЕАЛЬНО Нужен был ГОРБ Boeing 747?

ASP.NET Core Logging Crash Course

ASP.NET Core Logging Crash Course

Признаки свержения автократий. S09E20

Признаки свержения автократий. S09E20

Сисадмины больше не нужны? Gemini настраивает Linux сервер и устанавливает cтек N8N. ЭТО ЗАКОННО?

Сисадмины больше не нужны? Gemini настраивает Linux сервер и устанавливает cтек N8N. ЭТО ЗАКОННО?

Logging in ASP NET Core

Logging in ASP NET Core

ШЕНДЕРОВИЧ: У Адама Кадырова не было шанса. Трамп и медаль. Путин и мир. Гренландия. Чебурашка

ШЕНДЕРОВИЧ: У Адама Кадырова не было шанса. Трамп и медаль. Путин и мир. Гренландия. Чебурашка

Морские перевозки: Кому принадлежат и как работают

Морские перевозки: Кому принадлежат и как работают

Часть 30 — Учебник по C# — Интерфейсы в c#.avi

Часть 30 — Учебник по C# — Интерфейсы в c#.avi

Асинхронные и Синхронные двигатели и генераторы. Мощный #энерголикбез ПЕРСПЕКТИВЫ ЭЛЕКТРОДВИГАТЕЛЕЙ

Асинхронные и Синхронные двигатели и генераторы. Мощный #энерголикбез ПЕРСПЕКТИВЫ ЭЛЕКТРОДВИГАТЕЛЕЙ

Configure ASP NET Core request processing pipeline

Configure ASP NET Core request processing pipeline

Путин перестал говорить о войне | Что случилось (English subtitles)

Путин перестал говорить о войне | Что случилось (English subtitles)

© 2025 dtub. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: infodtube@gmail.com