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 Microsoft.Extensions.FileProviders;
|
||||||
|
using Serilog;
|
||||||
|
using SVSim.Hosting;
|
||||||
|
|
||||||
namespace SVSim.ContentServer;
|
namespace SVSim.ContentServer;
|
||||||
|
|
||||||
@@ -21,7 +23,10 @@ public class Program
|
|||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
var builder = WebApplication.CreateBuilder(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.
|
// Env var takes priority — it's the canonical knob per the spec docs.
|
||||||
var contentRoot = Environment.GetEnvironmentVariable("SVSIM_CONTENT_ROOT")
|
var contentRoot = Environment.GetEnvironmentVariable("SVSIM_CONTENT_ROOT")
|
||||||
?? builder.Configuration["Content:Root"];
|
?? builder.Configuration["Content:Root"];
|
||||||
@@ -83,5 +88,15 @@ public class Program
|
|||||||
"content-addressed under /dl/Resource/ and /dl/Sound/.");
|
"content-addressed under /dl/Resource/ and /dl/Sound/.");
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Fatal(ex, "Host terminated unexpectedly");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Log.CloseAndFlush();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,4 +8,8 @@
|
|||||||
<RootNamespace>SVSim.ContentServer</RootNamespace>
|
<RootNamespace>SVSim.ContentServer</RootNamespace>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\SVSim.Hosting\SVSim.Hosting.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -5,6 +5,14 @@
|
|||||||
"Microsoft.AspNetCore": "Warning"
|
"Microsoft.AspNetCore": "Warning"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"Serilog": {
|
||||||
|
"MinimumLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Override": {
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*",
|
||||||
"Content": {
|
"Content": {
|
||||||
"Root": ""
|
"Root": ""
|
||||||
|
|||||||
Reference in New Issue
Block a user