The default project template has the following logging configuration in appSettings.json
:
"Logging": {
"IncludeScopes": true,
"LogLevel":
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
What are Default
, System
and Microsoft
for?
Both the System
and Microsoft
namespace assemblies have a logging level that is honored. Consider an MVC 6 application, imagine in your project.json
that you have a dependency of "Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final"
- this assembly is prefixed with "Microsoft". Internally its logging will be output with the level specified in your config.
Likewise, in your application "Default"
is relevant to your application. Consider the following:
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
}
So if you set "Microsoft": "Critical"
and internally MVC encounters and logs an exception via the logger.LogError
method, it will not be written in the output of the log.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With