Skip to content

HttpLogging redaction and enrichment #31844

Closed
@jkotalik

Description

@jkotalik

We need the ability to allow users to configure and customize what is logged for a request and response. For example if they would like to modify a header value that is logged to remove PII, or adding another key and value to the log.

Our current idea is to have a Func that people can implement that would take a context, and allow returning any KeyValuePair to be logged.

Currently, we were thinking of adding the extension point to where we log headers:

General API shape

Action<HttpLoggingContext> ModifyLog;

HttpLogContext
{
    HttpContext HttpContext { get; }
    List<KeyValuePair<string, string>> Logs { get; } // or maybe a dictionary
}

Example:

(httpLogContext) =>
{
   httpLogContext.Logs.Add(
       new KeyValuePair<string, string>(
           "RequestAborted", 
            httpLogContext.HttpContext.RequestAborted.IsCancellationRequested.ToString());
}

Metadata

Metadata

Assignees

Labels

api-approvedAPI was approved in API review, it can be implementedarea-middlewareIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewares

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions