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:

  1. "Logging": {
  2. "LogLevel": {
  3. "Default": "Warning",
  4. "StudentManagement.Controllers.HomeController": "Trace",
  5. "StudentManagement.Models.SQLStudentRepository": "Error",
  6. "Microsoft": "Information"
  7. }
  8. }

给 Debug 界面指定 LogLevel:

  1. "Logging": {
  2. "Debug": {
  3. "LogLevel": {
  4. "Default": "Warning",
  5. "StudentManagement.Controllers.HomeController": "Warning",
  6. "StudentManagement.Models.SQLStudentRepository": "Warning",
  7. "Microsoft": "Warning"
  8. }
  9. },
  10. "LogLevel": {
  11. "Default": "Trace",
  12. "StudentManagement.Controllers.HomeController": "Trace",
  13. "StudentManagement.Models.SQLStudentRepository": "Trace",
  14. "Microsoft": "Trace"
  15. }
  16. }