From 963649b2b7b38e5031ae568a5e5814898fda6285 Mon Sep 17 00:00:00 2001 From: lihanbo Date: Wed, 16 Oct 2024 11:24:49 +0800 Subject: [PATCH] FIx error `The logger is already frozen` --- LFlow/Program.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/LFlow/Program.cs b/LFlow/Program.cs index 4f38d7b..773794e 100644 --- a/LFlow/Program.cs +++ b/LFlow/Program.cs @@ -58,7 +58,13 @@ public static class Program }); }); - builder.Host.UseSerilog(Log.Logger); + builder.Host.UseSerilog((context, services, config) => + { + config.ReadFrom.Configuration(context.Configuration) + .ReadFrom.Services(services) + .Enrich.FromLogContext(); + // .WriteTo.Console(); + }, true); // init App.service App.services = builder.Services; var app = builder.Build();