From def4d7b7c7b86d98bfb62d07f73a9f0498e12efb Mon Sep 17 00:00:00 2001 From: TekH Date: Mon, 13 Jul 2026 09:51:01 +0200 Subject: [PATCH] refactor: Move log directory configuration to Application section - Move LogDirectory from Logging section to Application section in appsettings.json - Update Program.cs to read from Application:LogDirectory instead of Logging:LogDirectory - Fix JSON schema validation warning for non-standard Logging properties - Application section now holds custom application-specific settings - Standard Logging and Serilog sections remain clean and schema-compliant --- ECMJobRunner.WebCron/Program.cs | 8 ++++---- ECMJobRunner.WebCron/appsettings.json | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ECMJobRunner.WebCron/Program.cs b/ECMJobRunner.WebCron/Program.cs index 397da17..8a9f128 100644 --- a/ECMJobRunner.WebCron/Program.cs +++ b/ECMJobRunner.WebCron/Program.cs @@ -19,8 +19,8 @@ var tempConfig = new ConfigurationBuilder() .Build(); // Get log directory from configuration -var logDirectory = tempConfig.GetValue("Logging:LogDirectory") - ?? throw new InvalidOperationException("Logging:LogDirectory not found in configuration."); +var logDirectory = tempConfig.GetValue("Application:LogDirectory") + ?? throw new InvalidOperationException("Application:LogDirectory not found in configuration."); var sqliteDbPath = Path.Combine(logDirectory, "logs.db"); Console.WriteLine($"[INFO] SQLite Log Database Path: {sqliteDbPath}"); @@ -101,8 +101,8 @@ builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(); // Add Serilog.UI with SQLite provider - use same path from configuration -var serilogUiLogDirectory = builder.Configuration.GetValue("Logging:LogDirectory") - ?? throw new InvalidOperationException("Logging:LogDirectory not found in configuration."); +var serilogUiLogDirectory = builder.Configuration.GetValue("Application:LogDirectory") + ?? throw new InvalidOperationException("Application:LogDirectory not found in configuration."); var serilogUiDbPath = Path.Combine(serilogUiLogDirectory, "logs.db"); builder.Services.AddSerilogUi(logUIOpt => diff --git a/ECMJobRunner.WebCron/appsettings.json b/ECMJobRunner.WebCron/appsettings.json index 7899564..8120d86 100644 --- a/ECMJobRunner.WebCron/appsettings.json +++ b/ECMJobRunner.WebCron/appsettings.json @@ -3,8 +3,7 @@ "LogLevel": { "Default": "Information", "Microsoft.AspNetCore": "Warning" - }, - "LogDirectory": "E:\\LogFiles\\Digital Data\\ECMJobRunner.WebCron" + } }, "ConnectionStrings": { "SDD-VMP04-SQL17": "Server=SDD-VMP04-SQL17\\DD_DEVELOP01;Database=DD_ECM;User Id=sa;Password=dd;Encrypt=false;TrustServerCertificate=True;" @@ -18,5 +17,8 @@ }, "ReC": { "ApiUrl": "http://172.24.12.39:90" + }, + "Application": { + "LogDirectory": "E:\\LogFiles\\Digital Data\\ECMJobRunner.WebCron" } }