File tree Expand file tree Collapse file tree 1 file changed +5
-11
lines changed
examples/aspnetcore-with-serilog Expand file tree Collapse file tree 1 file changed +5
-11
lines changed Original file line number Diff line number Diff 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 ();
You can’t perform that action at this time.
0 commit comments