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": ""