Extensions for configuration Serilog
Middleware add request body to DiagnosticContext. It's can be usefull in case you use UseSerilogRequestLogging extension.
Extension has 2 modes of body logging:
- for exception only (by default)
- for all requests
Please, keep the order
app.UseSerilogRequestLogging();
app.UseRequestBodyLogging(c=>c.Mode = RequestBodyLoggingMode.Only4xx | RequestBodyLoggingMode.Only5xx);
Added property RequestBody
to context
ActionName
and ControllerName
added to Serilog diagnostic context
Code was borrowed from Andrew Lock
services.AddControllers(opts =>
{
opts.Filters.Add<ActionNameLoggingFilter>();
});
Added properties to context RouteData
, ActionName
, ActionId
, ValidationState
RequestLoggingHandler add HttpClient
requests logging like an UseSerilogRequestLogging format.
services.AddHttpClientRequestLogging();
Or you can use RequestLoggingHandler
in HttpClient
constructor
Added logs for HttpClient
requests