Skip to content

Commit ebd321d

Browse files
andreychastt-anch
andauthored
Update readme in ASP.NET Core with Serilog example (#337)
Co-authored-by: Andrei Chasovskikh <andrei.chasovskikh@go-springtime.com>
1 parent 79ef258 commit ebd321d

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

examples/aspnetcore-with-serilog/README.md

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,13 @@ public static IWebHost BuildWebHost(string[] args) =>
3333
.UseStartup<Startup>()
3434
.UseSerilog((ctx, config) =>
3535
{
36-
config.ReadFrom.Configuration(ctx.Configuration);
37-
38-
// Ensure HttpContextAccessor is accessible
36+
// Ensure HttpContextAccessor is accessible
3937
var httpAccessor = ctx.Configuration.Get<HttpContextAccessor>();
40-
41-
// Create a formatter configuration to se this accessor
42-
var formatterConfig = new EcsTextFormatterConfiguration();
43-
formatterConfig.MapHttpContext(httpAccessor);
44-
45-
// Write events to the console using this configration
46-
var formatter = new EcsTextFormatter(formatterConfig);
4738

48-
config.WriteTo.Console(formatter);
39+
config
40+
.ReadFrom.Configuration(ctx.Configuration)
41+
.Enrich.WithEcsHttpContext(httpAccessor)
42+
.WriteTo.Async(a => a.Console(new EcsTextFormatter()));
4943
})
5044
.UseKestrel()
5145
.Build();

0 commit comments

Comments
 (0)