I am using NLog with dotnet core app configured like described here. https://github.com/NLog/NLog.Web/wiki/Getting-started-with-ASP.NET-Core-2
In nlog.config if I set minLevel to Error and launch my app I can see on logger that logDebug is disabled.
If I restore back to trace then all levels are set to true (error, trace, debug, info, warning)
and if I put this into config file (appsettings.json)
"Logging": {
"LogLevel": {
"Default": "Error",
"Microsoft": "Information"
}
}
then nothing happens, all logger levels are still set to true, what might be wrong ?

As Snakefoot mentioned,
this is the config of Microsoft Extension Logging.
When using NLog + Injected .NET Core loggers (using Microsoft Extension Logging), the flow is as follows:
ILogger<MyClass> → LoggerFactory in Microsoft Extension Logging → LogFactory in NLog.
To configure NLog, you should update the NLog <rules> in your nlog.config, e.g.
(also possible from code, see docs)
<rules>
<logger name="*" minlevel="debug" />
</rules>
Please note that you won't see debug logs if the minlevel is "debug" in NLog and "error" the appsettings.json
note 2:
When using NLog direct, e.g. the NLog.LogManager.GetCurrentClassLogger(), you only need to configure NLog and the appsettings.json config isn't used for those logs.
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