serilog-aspnetcore
serilog-aspnetcore copied to clipboard
Add EnrichDiagnosticContextAsync as async addition
Is your feature request related to a problem? Please describe. I want to enrich the http logging with Serilog by parts of the request body. Therefore, I read from the request body which must be done async. However, if a set EnrichDiagnosticContext to an async method like the following I get the VSTHRD101 warning:
options.EnrichDiagnosticContext = async (context, httpContext) =>
{
await LogHelper.EnrichFromRequestAsync(context, httpContext);
};
Describe the solution you'd like
In addition to the Action<IDiagnosticContext, HttpContext>? EnrichDiagnosticContext, there should be a Func<IDiagnosticContext, HttpContext, Task>? EnrichDiagnosticContextAsync that can be called asynchronously and returns just a Task.
I've added a PR to resolve this.