-
Notifications
You must be signed in to change notification settings - Fork 213
Closed
Description
First, let me say thanks for providing this excellent set of projects. There are a lot of great features and impressive documentation of the capabilites provided. The following issue may be due to me misunderstanding something, but I think it is a bug.
I am using Serilog.AspNetCore 3.2.0-dev-00133 as I wanted to take advantage of EnrichDiagnosticContext which has recently been added, in order to easily log request headers when using the RequestLoggingMiddleware.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseSerilogRequestLogging(options =>
{
options.MessageTemplate = MessageTemplate;
options.EnrichDiagnosticContext = (diagnosticContext, httpContext) =>
{
diagnosticContext.Set("Headers", httpContext.Request.Headers);
};
});
app.UseMvc();
}
However, the headers do not appear in the logged event. Looking at the code for RequestLoggingMiddleware.LogCompletion Lines 81-85 are:
if (!collector.TryComplete(out var collectedProperties))
collectedProperties = NoProperties;
// Enrich diagnostic context
_enrichDiagnosticContext?.Invoke(_diagnosticContext, httpContext);
shouldn't the call to enrich appear before collector.TryComplete as per this comment?
Metadata
Metadata
Assignees
Labels
No labels