Open ducalai opened 4 years ago
You can create / update the Configuration with the values from the mentioned API before building the host.
So, in Program.cs using .ConfigureLogging(this IWebHostBuilder hostBuilder, Action<WebHostBuilderContext, ILoggingBuilder> configureLogging)
extension method? Once host is created, it is no more possible?
Logging monitors config for changes and reloads, so if your configuration source supports reloading (such as the built-in JSON one), then changing the file will automatically trigger a reload and reconfiguration of logging without requiring a restart of the app.
dynamic seting ILogger's LogLevel at runtime is very very useful @anurse
Tagging subscribers to this area: @maryamariyan See info in area-owners.md if you want to be subscribed.
Author: | ducalai |
---|---|
Assignees: | - |
Labels: | `area-Extensions-Logging`, `untriaged` |
Milestone: | - |
We have a scenario where our application should get its logging
LogLevel
configuration using an API. Then, we would like to set it at runtime. I know Serilog supports it usingLoggingLevelSwitch
, but how to solve it directly in Microsoft.Extensions.Logging? If not possible now, are you planning to support it?