加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

ASP.NET Core MVC 6中的默认,系统和Mi??crosoft LogLevels是什么

发布时间:2020-12-16 09:56:03 所属栏目:asp.Net 来源:网络整理
导读:默认项目模板在appSettings.json中具有以下日志记录配置: "Logging": { "IncludeScopes": true,"LogLevel": "Default": "Debug","System": "Information","Microsoft": "Information" }} 什么是默认,系统和微软? 解决方法 System和Microsoft命名空间程序集
默认项目模板在appSettings.json中具有以下日志记录配置:

"Logging": {
  "IncludeScopes": true,"LogLevel": 
    "Default": "Debug","System": "Information","Microsoft": "Information"
  }
}

什么是默认,系统和微软?

解决方法

System和Microsoft命名空间程序集都具有值得尊重的日志记录级别.考虑一个MVC 6应用程序,想象一下你的project.json你有一个依赖“Microsoft.AspNetCore.Mvc”:“1.0.0-rc2-final” – 这个程序集以“Microsoft”为前缀.在内部,它的日志记录将以您的配置中指定的级别输出.

同样,在您的应用程序中,“默认”与您的应用程序相关.考虑以下:

void FooBar(ILogger logger)
{
    logger.LogCritical("LoglLevel.Critical");
    logger.LogDebug("LoglLevel.Debug");
    logger.LogError("LoglLevel.Errror");
    logger.LogInformation("LoglLevel.Information");
    logger.LogTrace("LoglLevel.Trace"); // This message would not be written
    logger.LogWarning("LoglLevel.Warning");
}

// This is the severity
public enum LogLevel
{
    Trace,Debug,Information,Warning,Error,Critical,None
}

因此,如果您设置“Microsoft”:“Critical”并且内部MVC遇到并通过logger.LogError方法记录异常,则不会将其写入日志的输出中.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读