From 57df329923c9796ef73fec87b4006038d21b8103 Mon Sep 17 00:00:00 2001 From: gamer147 Date: Sat, 4 Jul 2026 02:08:44 -0400 Subject: [PATCH] content: wire Serilog into SVSim.ContentServer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Calls UseSvSimSerilog("svsim-content") right after CreateBuilder and wraps Main in try/catch/finally. No environment gate needed — ContentServer has no test-suite path. The existing manual request-log middleware (uses ILogger) now flows through Serilog automatically; swapping it for UseSerilogRequestLogging() is a follow-up per the spec. Co-Authored-By: Claude Opus 4.7 --- SVSim.ContentServer/Program.cs | 15 +++++++++++++++ SVSim.ContentServer/SVSim.ContentServer.csproj | 4 ++++ SVSim.ContentServer/appsettings.json | 8 ++++++++ 3 files changed, 27 insertions(+) diff --git a/SVSim.ContentServer/Program.cs b/SVSim.ContentServer/Program.cs index cfddfb86..dce3d91c 100644 --- a/SVSim.ContentServer/Program.cs +++ b/SVSim.ContentServer/Program.cs @@ -1,4 +1,6 @@ using Microsoft.Extensions.FileProviders; +using Serilog; +using SVSim.Hosting; namespace SVSim.ContentServer; @@ -21,7 +23,10 @@ public class Program public static void Main(string[] args) { var builder = WebApplication.CreateBuilder(args); + builder.Host.UseSvSimSerilog("svsim-content"); + try + { // Env var takes priority — it's the canonical knob per the spec docs. var contentRoot = Environment.GetEnvironmentVariable("SVSIM_CONTENT_ROOT") ?? builder.Configuration["Content:Root"]; @@ -83,5 +88,15 @@ public class Program "content-addressed under /dl/Resource/ and /dl/Sound/."); app.Run(); + } + catch (Exception ex) + { + Log.Fatal(ex, "Host terminated unexpectedly"); + throw; + } + finally + { + Log.CloseAndFlush(); + } } } diff --git a/SVSim.ContentServer/SVSim.ContentServer.csproj b/SVSim.ContentServer/SVSim.ContentServer.csproj index bd956c22..8e80ac2e 100644 --- a/SVSim.ContentServer/SVSim.ContentServer.csproj +++ b/SVSim.ContentServer/SVSim.ContentServer.csproj @@ -8,4 +8,8 @@ SVSim.ContentServer + + + + diff --git a/SVSim.ContentServer/appsettings.json b/SVSim.ContentServer/appsettings.json index 193f158e..f3008dae 100644 --- a/SVSim.ContentServer/appsettings.json +++ b/SVSim.ContentServer/appsettings.json @@ -5,6 +5,14 @@ "Microsoft.AspNetCore": "Warning" } }, + "Serilog": { + "MinimumLevel": { + "Default": "Information", + "Override": { + "Microsoft.AspNetCore": "Warning" + } + } + }, "AllowedHosts": "*", "Content": { "Root": ""