From 9aa360efead4b75f76ce5f00a8e2e49360133871 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Kurzyniec?= Date: Tue, 12 Nov 2019 10:15:50 +0100 Subject: [PATCH] Fix for issue #31 Getting correlationId from response header to avoid creating it again in CorrelationIdHeaderEnricher --- .../Enrichers/CorrelationIdHeaderEnricher.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Serilog.Enrichers.CorrelationId/Enrichers/CorrelationIdHeaderEnricher.cs b/src/Serilog.Enrichers.CorrelationId/Enrichers/CorrelationIdHeaderEnricher.cs index 4494549..091192b 100644 --- a/src/Serilog.Enrichers.CorrelationId/Enrichers/CorrelationIdHeaderEnricher.cs +++ b/src/Serilog.Enrichers.CorrelationId/Enrichers/CorrelationIdHeaderEnricher.cs @@ -48,6 +48,10 @@ private string GetCorrelationId() { header = values.FirstOrDefault(); } + else if (_contextAccessor.HttpContext.Response.Headers.TryGetValue(_headerKey, out values)) + { + header = values.FirstOrDefault(); + } var correlationId = string.IsNullOrEmpty(header) ? Guid.NewGuid().ToString()