Skip to content

Add EnrichDiagnosticContextAsync as async addition #345

Open
@hbunjes

Description

@hbunjes

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions