content: wire Serilog into SVSim.ContentServer
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<Program>) now flows through Serilog
automatically; swapping it for UseSerilogRequestLogging() is a
follow-up per the spec.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,4 +8,8 @@
|
||||
<RootNamespace>SVSim.ContentServer</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\SVSim.Hosting\SVSim.Hosting.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -5,6 +5,14 @@
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"Serilog": {
|
||||
"MinimumLevel": {
|
||||
"Default": "Information",
|
||||
"Override": {
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"Content": {
|
||||
"Root": ""
|
||||
|
||||
Reference in New Issue
Block a user