LogLevel
LogLevel 表示所记录消息的严重性
Trace = 0 | LogTrace() |
---|---|
Debug = 1 | LogDebug() |
Information = 2 | LogInformation() |
Warning = 3 | LogWarning() |
Error = 4 | LogError() |
Critical = 5 | LogCritical() |
None = 6 | N/A |
过滤日志
日志可以通过以下方式进行筛选:
- LogCategory
- LoggingProvider
appsettings.json 中指定类的 LogLevel:
"Logging": {
"LogLevel": {
"Default": "Warning",
"StudentManagement.Controllers.HomeController": "Trace",
"StudentManagement.Models.SQLStudentRepository": "Error",
"Microsoft": "Information"
}
}
给 Debug 界面指定 LogLevel:
"Logging": {
"Debug": {
"LogLevel": {
"Default": "Warning",
"StudentManagement.Controllers.HomeController": "Warning",
"StudentManagement.Models.SQLStudentRepository": "Warning",
"Microsoft": "Warning"
}
},
"LogLevel": {
"Default": "Trace",
"StudentManagement.Controllers.HomeController": "Trace",
"StudentManagement.Models.SQLStudentRepository": "Trace",
"Microsoft": "Trace"
}
}