I have Asp.NET Core application that uses a third-party library that outputs messages with the INFO information level:
_logger.LogInformation("About information...");
This is about how the log display is configured (I use a JSON configuration):
{
"NLog": {
"targets": {
"console": {
"type": "Console",
"layout": "${logger}|${date}|${level:uppercase=true}|${message}"
}
}
}
}
ThirdPartyNamespace.Runner|2024/11/12 12:24:27.141|INFO|About information...
In the logs for the logging level, I logically check INFO. Is it possible to redefine the logging level for a specific logger without changing the code from INFO to DEBUG?
This rule doesn't work (I get an exception: Unhandled exception. NLog.NLogConfigurationException: 'ConditionBasedFilter' cannot assign unknown property 'level'='Debug'). Maybe there is a right working way?
{
"rules": [
{
"logger": "ThirdPartyNamespace.Runner",
"minLevel": "Debug",
"writeTo": "Console",
"filters": [
{
"type": "when",
"condition": "level == LogLevel.Info",
"action": "Log",
"level": "Debug"
}
]
}
]
}
minLevelandmaxLevel. here is the document you could refer to get more detail about what is the use of the filter and how it works github.com/NLog/NLog/wiki/Configuration-file#rules. i have tested some of the code but non if the code works for your requirement