Closed
Description
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());
}