diff --git a/src/Server/ZB.MOM.WW.OtOpcUa.Host/Program.cs b/src/Server/ZB.MOM.WW.OtOpcUa.Host/Program.cs index 4a9dd50c..9ae0abb7 100644 --- a/src/Server/ZB.MOM.WW.OtOpcUa.Host/Program.cs +++ b/src/Server/ZB.MOM.WW.OtOpcUa.Host/Program.cs @@ -20,6 +20,7 @@ using ZB.MOM.WW.OtOpcUa.Runtime; using ZB.MOM.WW.OtOpcUa.Security; using ZB.MOM.WW.OtOpcUa.Security.Endpoints; using ZB.MOM.WW.OtOpcUa.Security.Ldap; +using ZB.MOM.WW.Telemetry.Serilog; // Roles drive the entire conditional wiring below — see ZB.MOM.WW.OtOpcUa.Cluster.RoleParser. var roles = RoleParser.Parse(Environment.GetEnvironmentVariable("OTOPCUA_ROLES")); @@ -45,11 +46,10 @@ var roleSuffix = roles.Length == 0 ? null : string.Join('-', roles.OrderBy(r => if (roleSuffix is not null) builder.Configuration.AddJsonFile($"appsettings.{roleSuffix}.json", optional: true, reloadOnChange: true); -// Serilog — rolling daily file sink per CLAUDE.md. Console for local dev. -builder.Host.UseSerilog((ctx, lc) => lc - .ReadFrom.Configuration(ctx.Configuration) - .WriteTo.Console() - .WriteTo.File("logs/otopcua-.log", rollingInterval: RollingInterval.Day)); +// Serilog — shared ZB.MOM.WW.Telemetry bootstrap. Sinks (Console + rolling daily file) +// now live in appsettings.json (ReadFrom.Configuration); AddZbSerilog layers in the +// shared NodeHostname / TraceContext / Redaction enrichers and trace correlation. +builder.AddZbSerilog(o => o.ServiceName = "otopcua"); // Windows-service registration is handled at install time by scripts/install/Install-Services.ps1 // (Task 62) rather than in-process, so the binary stays cross-platform-compilable. diff --git a/src/Server/ZB.MOM.WW.OtOpcUa.Host/appsettings.json b/src/Server/ZB.MOM.WW.OtOpcUa.Host/appsettings.json index 0967ef42..ec8ed457 100644 --- a/src/Server/ZB.MOM.WW.OtOpcUa.Host/appsettings.json +++ b/src/Server/ZB.MOM.WW.OtOpcUa.Host/appsettings.json @@ -1 +1,9 @@ -{} +{ + "Serilog": { + "Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File" ], + "WriteTo": [ + { "Name": "Console" }, + { "Name": "File", "Args": { "path": "logs/otopcua-.log", "rollingInterval": "Day" } } + ] + } +}