116 references to HttpLoggingTagNames
Microsoft.AspNetCore.Diagnostics.Middleware (4)
Logging\HttpLoggingRedactionInterceptor.cs (3)
59_requestHeadersReader = new(optionsValue.RequestHeadersDataClasses, redactorProvider, HttpLoggingTagNames.RequestHeaderPrefix); 60_responseHeadersReader = new(optionsValue.ResponseHeadersDataClasses, redactorProvider, HttpLoggingTagNames.ResponseHeaderPrefix); 83logContext.AddParameter(HttpLoggingTagNames.Host, context.Request.Host.Value);
Logging\RequestHeadersLogEnricher.cs (1)
39_normalizedHeaders = HeaderNormalizer.PrepareNormalizedHeaderNames(_headersDataClasses, HttpLoggingTagNames.RequestHeaderPrefix);
Microsoft.AspNetCore.Diagnostics.Middleware.Tests (112)
Logging\AcceptanceTests.cs (80)
230Assert.DoesNotContain(state, x => x.Key == HttpLoggingTagNames.RequestBody); 231Assert.DoesNotContain(state, x => x.Key.StartsWith(HttpLoggingTagNames.RequestHeaderPrefix)); 232Assert.DoesNotContain(state, x => x.Key.StartsWith(HttpLoggingTagNames.ResponseHeaderPrefix)); 233Assert.Single(state, x => x.Key == HttpLoggingTagNames.Host && !string.IsNullOrEmpty(x.Value)); 234Assert.Single(state, x => x.Key == HttpLoggingTagNames.Path && x.Value == TelemetryConstants.Unknown); 235Assert.Single(state, x => x.Key == HttpLoggingTagNames.StatusCode && x.Value == responseStatus); 236Assert.Single(state, x => x.Key == HttpLoggingTagNames.Method && x.Value == HttpMethod.Post.ToString()); 237Assert.Single(state, x => x.Key == HttpLoggingTagNames.Duration && 243Assert.Single(state, x => x.Key == HttpLoggingTagNames.ResponseBody && x.Value == "Server: hello!Server: world!"); 248Assert.DoesNotContain(state, x => x.Key == HttpLoggingTagNames.ResponseBody); 290Assert.DoesNotContain(state, x => x.Key == HttpLoggingTagNames.ResponseBody); 291Assert.DoesNotContain(state, x => x.Key.StartsWith(HttpLoggingTagNames.RequestHeaderPrefix)); 292Assert.DoesNotContain(state, x => x.Key.StartsWith(HttpLoggingTagNames.ResponseHeaderPrefix)); 293Assert.Single(state, x => x.Key == HttpLoggingTagNames.Host && !string.IsNullOrEmpty(x.Value)); 294Assert.Single(state, x => x.Key == HttpLoggingTagNames.Path && x.Value == TelemetryConstants.Unknown); 295Assert.Single(state, x => x.Key == HttpLoggingTagNames.StatusCode && x.Value == responseStatus); 296Assert.Single(state, x => x.Key == HttpLoggingTagNames.Method && x.Value == HttpMethod.Post.ToString()); 297Assert.Single(state, x => x.Key == HttpLoggingTagNames.Duration && 303Assert.Single(state, x => x.Key == HttpLoggingTagNames.RequestBody && x.Value == Content); 308Assert.DoesNotContain(state, x => x.Key == HttpLoggingTagNames.RequestBody); 343Assert.DoesNotContain(state, x => x.Key == HttpLoggingTagNames.ResponseBody); 344Assert.DoesNotContain(state, x => x.Key.StartsWith(HttpLoggingTagNames.RequestHeaderPrefix)); 345Assert.DoesNotContain(state, x => x.Key.StartsWith(HttpLoggingTagNames.ResponseHeaderPrefix)); 346Assert.Single(state, x => x.Key == HttpLoggingTagNames.Host && !string.IsNullOrEmpty(x.Value)); 347Assert.Single(state, x => x.Key == HttpLoggingTagNames.Path && x.Value == "/myroute/123"); 348Assert.Single(state, x => x.Key == HttpLoggingTagNames.StatusCode && x.Value == responseStatus); 349Assert.Single(state, x => x.Key == HttpLoggingTagNames.Method && x.Value == HttpMethod.Post.ToString()); 350Assert.Single(state, x => x.Key == HttpLoggingTagNames.Duration && 403Assert.DoesNotContain(requestState, x => x.Key.StartsWith(HttpLoggingTagNames.ResponseHeaderPrefix)); 404Assert.DoesNotContain(requestState, x => x.Key == HttpLoggingTagNames.StatusCode); 405Assert.DoesNotContain(requestState, x => x.Key == HttpLoggingTagNames.Duration); 406Assert.Single(requestState, x => x.Key == HttpLoggingTagNames.RequestHeaderPrefix + NormalizedRequestHeader); 407Assert.Single(requestState, x => x.Key == HttpLoggingTagNames.Host && !string.IsNullOrEmpty(x.Value)); 408Assert.Single(requestState, x => x.Key == HttpLoggingTagNames.Path && x.Value == TelemetryConstants.Unknown); 409Assert.Single(requestState, x => x.Key == HttpLoggingTagNames.Method && x.Value == HttpMethod.Post.ToString()); 416Assert.Single(responseState, x => x.Key == HttpLoggingTagNames.ResponseHeaderPrefix + NormalizedResponseHeader); 417Assert.Single(responseState, x => x.Key == HttpLoggingTagNames.StatusCode && x.Value == responseStatus); 423Assert.Single(durationState, x => x.Key == HttpLoggingTagNames.Duration && x.Value != null); 461Assert.Single(state, x => x.Key == HttpLoggingTagNames.RequestHeaderPrefix + NormalizedRequestHeader); 462Assert.Single(state, x => x.Key == HttpLoggingTagNames.ResponseHeaderPrefix + NormalizedResponseHeader); 463Assert.Single(state, x => x.Key == HttpLoggingTagNames.Host && !string.IsNullOrEmpty(x.Value)); 464Assert.Single(state, x => x.Key == HttpLoggingTagNames.Path && x.Value == TelemetryConstants.Unknown); 465Assert.Single(state, x => x.Key == HttpLoggingTagNames.StatusCode && x.Value == responseStatus); 466Assert.Single(state, x => x.Key == HttpLoggingTagNames.Duration && 470Assert.Single(state, x => x.Key == HttpLoggingTagNames.Method && x.Value == HttpMethod.Get.ToString()); 471Assert.DoesNotContain(state, x => x.Key == HttpLoggingTagNames.RequestBody); 472Assert.DoesNotContain(state, x => x.Key == HttpLoggingTagNames.ResponseBody); 474x.Key.StartsWith(HttpLoggingTagNames.RequestHeaderPrefix) && !x.Key.EndsWith(NormalizedRequestHeader)); 477x.Key.StartsWith(HttpLoggingTagNames.ResponseHeaderPrefix) && !x.Key.EndsWith(NormalizedResponseHeader)); 509Assert.Single(state, x => x.Key == HttpLoggingTagNames.Method && x.Value == HttpMethod.Delete.ToString()); 510Assert.DoesNotContain(state, x => x.Key == HttpLoggingTagNames.RequestBody); 511Assert.DoesNotContain(state, x => x.Key == HttpLoggingTagNames.ResponseBody); 512Assert.DoesNotContain(state, x => x.Key.StartsWith(HttpLoggingTagNames.RequestHeaderPrefix)); 513Assert.DoesNotContain(state, x => x.Key.StartsWith(HttpLoggingTagNames.ResponseHeaderPrefix)); 549Assert.Single(state, x => x.Key == HttpLoggingTagNames.Path && x.Value == RequestPath); 626Assert.DoesNotContain(firstRecord, x => x.Key == HttpLoggingTagNames.StatusCode); 627Assert.DoesNotContain(firstRecord, x => x.Key == HttpLoggingTagNames.Duration); 628Assert.DoesNotContain(secondRecord!, x => x.Key == HttpLoggingTagNames.Duration); 629Assert.DoesNotContain(fourthRecord, x => x.Key == HttpLoggingTagNames.StatusCode); 630Assert.DoesNotContain(fourthRecord, x => x.Key == HttpLoggingTagNames.Duration); 631Assert.DoesNotContain(fithRecord!, x => x.Key == HttpLoggingTagNames.Duration); 635Assert.Single(secondRecord!, x => x.Key == HttpLoggingTagNames.StatusCode && x.Value == responseStatus); 636Assert.Single(fithRecord!, x => x.Key == HttpLoggingTagNames.StatusCode && x.Value == responseStatus); 640Assert.Single(thirdRecord, x => x.Key == HttpLoggingTagNames.Duration && x.Value != null); 641Assert.Single(sixthRecord, x => x.Key == HttpLoggingTagNames.Duration && x.Value != null); 666Assert.DoesNotContain(state, x => x.Key.StartsWith(HttpLoggingTagNames.RequestHeaderPrefix)); 667Assert.DoesNotContain(state, x => x.Key.StartsWith(HttpLoggingTagNames.ResponseHeaderPrefix)); 668Assert.Single(state, x => x.Key == HttpLoggingTagNames.Method && x.Value == HttpMethod.Get.ToString()); 669Assert.Single(state, x => x.Key == HttpLoggingTagNames.Host && !string.IsNullOrEmpty(x.Value)); 670Assert.Single(state, x => x.Key == HttpLoggingTagNames.Path && x.Value == TelemetryConstants.Unknown); 671Assert.Single(state, x => x.Key == HttpLoggingTagNames.StatusCode && x.Value == expectedStatus); 672Assert.Single(state, x => x.Key == HttpLoggingTagNames.Duration && 707Assert.DoesNotContain(state, x => x.Key.StartsWith(HttpLoggingTagNames.RequestHeaderPrefix)); 708Assert.DoesNotContain(state, x => x.Key.StartsWith(HttpLoggingTagNames.ResponseHeaderPrefix)); 709Assert.Single(state, x => x.Key == HttpLoggingTagNames.Method && x.Value == HttpMethod.Put.ToString()); 710Assert.Single(state, x => x.Key == HttpLoggingTagNames.RequestBody && x.Value == Content); 711Assert.Single(state, x => x.Key == HttpLoggingTagNames.ResponseBody && x.Value == "test body"); 741Assert.DoesNotContain(state, x => x.Key.StartsWith(HttpLoggingTagNames.RequestHeaderPrefix)); 742Assert.DoesNotContain(state, x => x.Key.StartsWith(HttpLoggingTagNames.ResponseHeaderPrefix)); 743Assert.Single(state, x => x.Key == HttpLoggingTagNames.Method && x.Value == HttpMethod.Put.ToString());
Logging\AcceptanceTests.Mvc.cs (24)
81Assert.Single(state, x => x.Key == HttpLoggingTagNames.Host && !string.IsNullOrEmpty(x.Value)); 82Assert.Single(state, x => x.Key == HttpLoggingTagNames.Path && x.Value == redactedPath); 83Assert.Single(state, x => x.Key == HttpLoggingTagNames.StatusCode && x.Value == responseStatus); 84Assert.Single(state, x => x.Key == HttpLoggingTagNames.Method && x.Value == HttpMethod.Get.ToString()); 85Assert.Single(state, x => x.Key == HttpLoggingTagNames.Duration && 119Assert.Single(state, x => x.Key == HttpLoggingTagNames.Host && !string.IsNullOrEmpty(x.Value)); 120Assert.Single(state, x => x.Key == HttpLoggingTagNames.Path && x.Value == ActionRouteTemplate); 121Assert.Single(state, x => x.Key == HttpLoggingTagNames.StatusCode && x.Value == responseStatus); 122Assert.Single(state, x => x.Key == HttpLoggingTagNames.Method && x.Value == HttpMethod.Get.ToString()); 123Assert.Single(state, x => x.Key == HttpLoggingTagNames.Duration && 170Assert.Single(state, x => x.Key == HttpLoggingTagNames.Host && !string.IsNullOrEmpty(x.Value)); 172Assert.Single(state, x => x.Key == HttpLoggingTagNames.Path && x.Value == expectedPath); 173Assert.Single(state, x => x.Key == HttpLoggingTagNames.StatusCode && x.Value == responseStatus); 174Assert.Single(state, x => x.Key == HttpLoggingTagNames.Method && x.Value == HttpMethod.Get.ToString()); 175Assert.Single(state, x => x.Key == HttpLoggingTagNames.Duration && 206Assert.Single(state, x => x.Key == HttpLoggingTagNames.Host && !string.IsNullOrEmpty(x.Value)); 207Assert.Single(state, x => x.Key == HttpLoggingTagNames.Path && x.Value == $"/api/users/testUserId/someTestData"); 208Assert.Single(state, x => x.Key == HttpLoggingTagNames.StatusCode && x.Value == responseStatus); 209Assert.Single(state, x => x.Key == HttpLoggingTagNames.Method && x.Value == HttpMethod.Get.ToString()); 210Assert.Single(state, x => x.Key == HttpLoggingTagNames.Duration && 249Assert.Single(state, x => x.Key == HttpLoggingTagNames.Host && !string.IsNullOrEmpty(x.Value)); 250Assert.Single(state, x => x.Key == HttpLoggingTagNames.Path && x.Value == expectedPath); 251Assert.Single(state, x => x.Key == HttpLoggingTagNames.StatusCode && x.Value == responseStatus); 252Assert.Single(state, x => x.Key == HttpLoggingTagNames.Method && x.Value == HttpMethod.Get.ToString());
Logging\AcceptanceTests.Routing.cs (2)
139Assert.Equal(expectedHttpPath, state[HttpLoggingTagNames.Path]); 177Assert.Equal(httpRoute, state[HttpLoggingTagNames.Path]);
Logging\IncomingHttpDimensionsTests.cs (1)
16var dimensions = HttpLoggingTagNames.DimensionNames;
Logging\RequestHeadersEnricherTests.cs (5)
26private const string NormalizedHeaderKey1 = HttpLoggingTagNames.RequestHeaderPrefix + "x-requestid"; 27private const string NormalizedHeaderKey2 = HttpLoggingTagNames.RequestHeaderPrefix + "host"; 28private const string NormalizedHeaderKey3 = HttpLoggingTagNames.RequestHeaderPrefix + "nullheader"; 29private const string NormalizedHeaderKey4 = HttpLoggingTagNames.RequestHeaderPrefix + "x-platform"; 188Assert.False(enrichedState.ContainsKey(HttpLoggingTagNames.RequestHeaderPrefix + headerKey2));