From ebd321d9f50b76602e8bcde02e02ec23312868ec Mon Sep 17 00:00:00 2001 From: Andrei Chasovskikh Date: Thu, 28 Mar 2024 16:58:51 +0100 Subject: [PATCH] Update readme in ASP.NET Core with Serilog example (#337) Co-authored-by: Andrei Chasovskikh --- examples/aspnetcore-with-serilog/README.md | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/examples/aspnetcore-with-serilog/README.md b/examples/aspnetcore-with-serilog/README.md index 83ca7854..07ebc97b 100644 --- a/examples/aspnetcore-with-serilog/README.md +++ b/examples/aspnetcore-with-serilog/README.md @@ -33,19 +33,13 @@ public static IWebHost BuildWebHost(string[] args) => .UseStartup() .UseSerilog((ctx, config) => { - config.ReadFrom.Configuration(ctx.Configuration); - - // Ensure HttpContextAccessor is accessible + // Ensure HttpContextAccessor is accessible var httpAccessor = ctx.Configuration.Get(); - - // Create a formatter configuration to se this accessor - var formatterConfig = new EcsTextFormatterConfiguration(); - formatterConfig.MapHttpContext(httpAccessor); - - // Write events to the console using this configration - var formatter = new EcsTextFormatter(formatterConfig); - config.WriteTo.Console(formatter); + config + .ReadFrom.Configuration(ctx.Configuration) + .Enrich.WithEcsHttpContext(httpAccessor) + .WriteTo.Async(a => a.Console(new EcsTextFormatter())); }) .UseKestrel() .Build();