Enrich Serilog log events with properties from the current HttpContext.
To use the enricher, first install the NuGet package:
Install-Package Serilog.Enrichers.HttpContextInfoThen, apply the enricher to your LoggerConfiguration:
Log.Logger = new LoggerConfiguration()
.Enrich.WithRequest()
// ...other configuration...
.CreateLogger();The WithRequest() enricher will add the current HttpRequest properties to produced events.
The package includes:
WithRequest()- adds theHttpRequestfrom the current HttpContext.WithResponse()- adds theHttpResponsefrom the current HttpContext.