From f67b0e806e9597d13b5e7b7c869795efa387dd8d Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Wed, 28 Jan 2026 16:13:16 -0500 Subject: [PATCH] feat(configmanager): add Serilog file logging to UI and create README Configure Serilog for the ConfigManager UI application, replacing console logging with daily rolling file logs in logs/ directory with 30-day retention. Add shutdown handler to flush logs on exit. --- .../JdeScoping.ConfigManager.Ui/App.axaml.cs | 26 ++++++-- .../JdeScoping.ConfigManager.Ui/README.md | 64 +++++++++++++++++++ 2 files changed, 86 insertions(+), 4 deletions(-) create mode 100644 NEW/src/Utils/JdeScoping.ConfigManager.Ui/README.md diff --git a/NEW/src/Utils/JdeScoping.ConfigManager.Ui/App.axaml.cs b/NEW/src/Utils/JdeScoping.ConfigManager.Ui/App.axaml.cs index 90d50fa..4ef84f2 100644 --- a/NEW/src/Utils/JdeScoping.ConfigManager.Ui/App.axaml.cs +++ b/NEW/src/Utils/JdeScoping.ConfigManager.Ui/App.axaml.cs @@ -7,7 +7,8 @@ using JdeScoping.ConfigManager.Core.DependencyInjection; using JdeScoping.ConfigManager.Ui.Services; using JdeScoping.ConfigManager.Ui.ViewModels; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; +using Serilog; +using Serilog.Events; namespace JdeScoping.ConfigManager.Ui; @@ -37,6 +38,9 @@ public partial class App : Avalonia.Application { DataContext = Services.GetRequiredService() }; + + // Ensure logs are flushed on exit + desktop.ShutdownRequested += (_, _) => Log.CloseAndFlush(); } base.OnFrameworkInitializationCompleted(); @@ -44,10 +48,24 @@ public partial class App : Avalonia.Application private void ConfigureServices(IServiceCollection services) { + // Configure Serilog with daily rolling file + var logsPath = Path.Combine(AppContext.BaseDirectory, "logs"); + Directory.CreateDirectory(logsPath); + + Log.Logger = new LoggerConfiguration() + .MinimumLevel.Information() + .MinimumLevel.Override("Microsoft", LogEventLevel.Warning) + .MinimumLevel.Override("Avalonia", LogEventLevel.Warning) + .Enrich.FromLogContext() + .WriteTo.File( + path: Path.Combine(logsPath, "configmanager-.log"), + rollingInterval: RollingInterval.Day, + retainedFileCountLimit: 30, + outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] {Message:lj}{NewLine}{Exception}") + .CreateLogger(); + // Logging - services.AddLogging(builder => builder - .AddConsole() - .SetMinimumLevel(LogLevel.Debug)); + services.AddLogging(builder => builder.AddSerilog(dispose: true)); // Add all ConfigManager.Core services services.AddConfigManagerCore(); diff --git a/NEW/src/Utils/JdeScoping.ConfigManager.Ui/README.md b/NEW/src/Utils/JdeScoping.ConfigManager.Ui/README.md new file mode 100644 index 0000000..15b7aac --- /dev/null +++ b/NEW/src/Utils/JdeScoping.ConfigManager.Ui/README.md @@ -0,0 +1,64 @@ +# JdeScoping ConfigManager UI + +Graphical configuration management tool for JDE Scoping Tool settings. + +## Building + +```bash +dotnet build NEW/src/Utils/JdeScoping.ConfigManager.Ui/JdeScoping.ConfigManager.Ui.csproj +``` + +## Running + +```bash +dotnet run --project NEW/src/Utils/JdeScoping.ConfigManager.Ui/JdeScoping.ConfigManager.Ui.csproj +``` + +Or run the built executable directly. + +## Configuration Discovery + +The UI searches for configuration in this order: +1. `JDESCOPING_CONFIG_PATH` environment variable +2. Same directory as executable +3. `../JdeScoping.Host/` relative to executable +4. User config directory + +## Features + +### Configuration Sections +- **Data Sync** - Sync intervals and behavior +- **Data Access** - Batch sizes and timeouts +- **Authentication** - Session settings +- **LDAP** - Directory server configuration +- **Search** - Search behavior settings +- **Excel Export** - Export format options +- **Connection Strings** - Database connections (with provider-specific forms) + +### Pipeline Editor +- Visual pipeline flow editor +- Pre-script / Post-script management +- Transform configuration (ColumnDrop, ColumnRename, JdeDate, Regex) +- Source and destination editing +- Reorder steps via move up/down + +### Secret Management +- SecureStore initialization +- View, add, edit, remove secrets +- Copy secret values to clipboard + +### Validation +- appsettings.json validation +- Pipeline configuration validation +- Results displayed in dialog + +## Logging + +Logs are written to the `logs/` directory relative to the executable: +- **Location:** `logs/configmanager-YYYYMMDD.log` +- **Rotation:** Daily with 30-day retention +- **Level:** Information (warnings and errors from framework components) + +## CLI Alternative + +For command-line usage, see the [ConfigManager CLI](../JdeScoping.ConfigManager.Cli/README.md).