-
Notifications
You must be signed in to change notification settings - Fork 166
Missing trace\debug logs in ASP.NET Core 6?
Rolf Kristensen edited this page Nov 8, 2022
·
8 revisions
Missing the trace and debug logs in ASP.NET Core 6?
Check your appsettings.json
The following is advised:
{
"Logging": {
"LogLevel": {
"Default": "Trace",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}
appsettings.json
. Ex. appsettings.development.json
Notice NLog.Web.AspNetCore ver. 5+ will by default ignore any filters configured in appsettings.json for Microsoft LoggerFactory. Instead it will only react to the logging-rules in NLog.config. The options ReplaceLoggerFactory
and RemoveLoggerFactoryFilter
in NLogAspNetCoreOptions
can be used to re-enable the old behavior. Example:
.UseNLog(new NLogAspNetCoreOptions() { RemoveLoggerFactoryFilter = false });
The recommended solution is updating the NLog configuration to include the wanted filtering:
<rules>
<logger name="System.*" finalMinLevel="Warn" /> <!-- Insert at the top -->
<logger name="Microsoft.*" finalMinLevel="Warn" /> <!-- Insert at the top -->
<!-- Everything else -->
</rules>
For general docs, check https://github.com/NLog/NLog/wiki