From c51b6f9ce40307adcaac5b760b44ab4e22eeddce Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Mon, 1 Jun 2026 15:43:10 -0400 Subject: [PATCH] =?UTF-8?q?feat(mxgateway):=20adopt=20AddZbSerilog=20?= =?UTF-8?q?=E2=80=94=20MEL=E2=86=92Serilog=20provider=20swap=20(behaviour-?= =?UTF-8?q?preserving)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ZB.MOM.WW.MxGateway.Server/GatewayApplication.cs | 3 +++ .../Gateway/GatewayApplicationTests.cs | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/ZB.MOM.WW.MxGateway.Server/GatewayApplication.cs b/src/ZB.MOM.WW.MxGateway.Server/GatewayApplication.cs index beba939..4ff780f 100644 --- a/src/ZB.MOM.WW.MxGateway.Server/GatewayApplication.cs +++ b/src/ZB.MOM.WW.MxGateway.Server/GatewayApplication.cs @@ -15,6 +15,7 @@ using ZB.MOM.WW.MxGateway.Server.Security.Authentication; using ZB.MOM.WW.MxGateway.Server.Security.Authorization; using ZB.MOM.WW.MxGateway.Server.Sessions; using ZB.MOM.WW.MxGateway.Server.Workers; +using ZB.MOM.WW.Telemetry.Serilog; namespace ZB.MOM.WW.MxGateway.Server; @@ -61,6 +62,8 @@ public static class GatewayApplication ConfigureSelfSignedTls(builder); + builder.AddZbSerilog(o => o.ServiceName = "mxgateway"); + builder.Services.AddGatewayConfiguration(); builder.Services.AddSqliteAuthStore(); builder.Services.AddGatewayGrpcAuthorization(); diff --git a/src/ZB.MOM.WW.MxGateway.Tests/Gateway/GatewayApplicationTests.cs b/src/ZB.MOM.WW.MxGateway.Tests/Gateway/GatewayApplicationTests.cs index 9fb3f05..1205d72 100644 --- a/src/ZB.MOM.WW.MxGateway.Tests/Gateway/GatewayApplicationTests.cs +++ b/src/ZB.MOM.WW.MxGateway.Tests/Gateway/GatewayApplicationTests.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using ZB.MOM.WW.MxGateway.Server; using ZB.MOM.WW.MxGateway.Server.Dashboard; @@ -29,6 +30,15 @@ public sealed class GatewayApplicationTests Assert.DoesNotContain("/health/live", paths); } + /// Verifies that Build registers Serilog as the host logging provider. + [Fact] + public void Build_UsesSerilogLoggerProvider() + { + using var app = GatewayApplication.Build([]); + var factory = app.Services.GetRequiredService(); + Assert.Equal("SerilogLoggerFactory", factory.GetType().Name); + } + /// Verifies that Build registers the gateway metrics service. [Fact] public async Task Build_RegistersGatewayMetrics()