From a51e3874532ffcd29a80525e580a8d5e746feb0d Mon Sep 17 00:00:00 2001 From: Flaminel Date: Thu, 4 Sep 2025 22:12:57 +0300 Subject: [PATCH] Fix log level change not taking effect (#292) --- .../Cleanuparr.Api/Controllers/ConfigurationController.cs | 6 +++--- .../Logging/LoggingConfigManager.cs | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/code/backend/Cleanuparr.Api/Controllers/ConfigurationController.cs b/code/backend/Cleanuparr.Api/Controllers/ConfigurationController.cs index 182786e8..f2320fdb 100644 --- a/code/backend/Cleanuparr.Api/Controllers/ConfigurationController.cs +++ b/code/backend/Cleanuparr.Api/Controllers/ConfigurationController.cs @@ -1173,6 +1173,9 @@ public class ConfigurationController : ControllerBase } } + // Handle logging configuration changes + var loggingChanged = HasLoggingConfigurationChanged(oldConfig.Log, newConfig.Log); + newConfig.Adapt(oldConfig, config); // Persist the configuration @@ -1185,9 +1188,6 @@ public class ConfigurationController : ControllerBase dynamicHttpClientFactory.UpdateAllClientsFromGeneralConfig(oldConfig); _logger.LogInformation("Updated all HTTP client configurations with new general settings"); - - // Handle logging configuration changes - var loggingChanged = HasLoggingConfigurationChanged(oldConfig.Log, newConfig.Log); if (loggingChanged.LevelOnly) { diff --git a/code/backend/Cleanuparr.Infrastructure/Logging/LoggingConfigManager.cs b/code/backend/Cleanuparr.Infrastructure/Logging/LoggingConfigManager.cs index c565f92c..b052e911 100644 --- a/code/backend/Cleanuparr.Infrastructure/Logging/LoggingConfigManager.cs +++ b/code/backend/Cleanuparr.Infrastructure/Logging/LoggingConfigManager.cs @@ -32,6 +32,7 @@ public static class LoggingConfigManager { using var context = DataContext.CreateStaticInstance(); var config = context.GeneralConfigs.AsNoTracking().First(); + SetLogLevel(config.Log.Level); const string categoryTemplate = "{#if Category is not null} {Concat('[',Category,']'),CAT_PAD}{#end}"; const string jobNameTemplate = "{#if JobName is not null} {Concat('[',JobName,']'),JOB_PAD}{#end}";