I am working on a .NET6 Kestrel application using appsettings.json for configuration and default console logging.
What I try to do is, that I want to change log-levels at runtime. However, so far the log-levels were only updated on restart.
Am I missing something besides reloadOnChange=true?
Here's the relevant code:

static void Configure(IConfigurationBuilder config)
{
config.AddJsonFile("appsettings.json", false, true);
config.AddEnvironmentVariables();
}
ConfigurationBuilder cb = new();
Configure(cb);
IConfigurationRoot configuration = cb.Build();
IWebHostBuilder webHost = WebHost
.CreateDefaultBuilder(args)
.ConfigureLogging(c =>
{
c.AddConfiguration(configuration);
c.AddConsole();
})
.ConfigureAppConfiguration(Configure)
.UseStartup<TStartup>();
Thank you all in advance!
You don't need to manually add these files because
CreateDefaultBuilderalready takes care of that for you.Additionally, when you run the app in Visual Studio, it automatically sets the "Development" environment variable (as specified in launchSettings.json). Consequently, the
appsettings.development.jsonfile will take precedence. Therefore, ensure that you are making changes in the correct file corresponding to the current environment.I've made a simple POC and it just works fine here, please give a try:
Program.cs
Changes on
appsettings.jsonfile immediately takes effect on logger output to console when calling the test endpoint.