From ca99bdfb944ed661ee39d268bfdbc4be64d27a54 Mon Sep 17 00:00:00 2001 From: sam Date: Sun, 13 Oct 2024 01:29:08 +0200 Subject: [PATCH] feat: log to seq --- Catalogger.Backend/Catalogger.Backend.csproj | 1 + Catalogger.Backend/Config.cs | 2 ++ Catalogger.Backend/Extensions/StartupExtensions.cs | 8 ++++++++ 3 files changed, 11 insertions(+) diff --git a/Catalogger.Backend/Catalogger.Backend.csproj b/Catalogger.Backend/Catalogger.Backend.csproj index baf29b4..73e806a 100644 --- a/Catalogger.Backend/Catalogger.Backend.csproj +++ b/Catalogger.Backend/Catalogger.Backend.csproj @@ -32,6 +32,7 @@ + diff --git a/Catalogger.Backend/Config.cs b/Catalogger.Backend/Config.cs index af27715..499f34a 100644 --- a/Catalogger.Backend/Config.cs +++ b/Catalogger.Backend/Config.cs @@ -16,6 +16,8 @@ public class Config public int MetricsPort { get; init; } = 5001; public bool EnableMetrics { get; init; } = true; + + public string? SeqLogUrl { get; init; } } public class DatabaseConfig diff --git a/Catalogger.Backend/Extensions/StartupExtensions.cs b/Catalogger.Backend/Extensions/StartupExtensions.cs index 1d4b822..0f2a47f 100644 --- a/Catalogger.Backend/Extensions/StartupExtensions.cs +++ b/Catalogger.Backend/Extensions/StartupExtensions.cs @@ -48,6 +48,14 @@ public static class StartupExtensions // The default theme doesn't support light mode .WriteTo.Console(theme: AnsiConsoleTheme.Sixteen); + if (config.Logging.SeqLogUrl != null) + { + logCfg.WriteTo.Seq( + config.Logging.SeqLogUrl, + restrictedToMinimumLevel: LogEventLevel.Verbose + ); + } + // AddSerilog doesn't seem to add an ILogger to the service collection, so add that manually. builder.Services.AddSerilog().AddSingleton(Log.Logger = logCfg.CreateLogger());