默认项目模板具有以下日志记录配置appSettings.json
:
"Logging": {
"IncludeScopes": true,
"LogLevel":
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
什么是Default
, System
and Microsoft
for?
这俩System
and Microsoft
命名空间程序集具有受尊重的日志记录级别。考虑一个MVC 6应用程序,想象一下您的project.json
你有一个依赖性"Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final"
- 该程序集带有“Microsoft”前缀。在内部,其日志记录将以配置中指定的级别输出。
同样,在您的应用程序中"Default"
与您的申请相关。考虑以下:
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
方法,不会写入日志的输出中。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)