Appsettings-based logging configuration controls logging providers through configuration files instead of changing Program.cs. It supports shared rules and environment-specific behavior for an ASP.NET Core application. section 7.2.4
Key implementation points:
- Define general thresholds under Logging:LogLevel, then add a provider-specific LogLevel subsection when one provider needs different filtering. section 7.2.4
- For example, set MyBGList to Information generally but Warning for the console provider, suppressing its informational custom message. section 7.2.4
- Provider settings are not interchangeable: unsupported options, such as Debug provider timestamp settings, are ignored. section 7.2.4
Override console verbosity
Add a Logging:Console:LogLevel:MyBGList value of Warning in appsettings.json, run or hot-reload the application, and check the command prompt for the missing informational message. section 7.2.4
"Logging": {
"LogLevel": {
"Default": "Warning",
"MyBGList": "Information"
},
"Console": {
"LogLevel": { #1
"MyBGList": "Warning"
},
"FormatterOptions": {
"TimestampFormat": "HH:mm:ss ",
"UseUtcTimestamp": true
}
}
}
Use this configuration listing to compare generic logging thresholds with a console-only category override. section 7.2.4
