108 references to HttpLoggingTagNames
Microsoft.AspNetCore.Diagnostics.Middleware (4)
Logging\HttpLoggingRedactionInterceptor.cs (3)
58
_requestHeadersReader = new(optionsValue.RequestHeadersDataClasses, redactorProvider,
HttpLoggingTagNames
.RequestHeaderPrefix);
59
_responseHeadersReader = new(optionsValue.ResponseHeadersDataClasses, redactorProvider,
HttpLoggingTagNames
.ResponseHeaderPrefix);
81
logContext.AddParameter(
HttpLoggingTagNames
.Host, context.Request.Host.Value);
Logging\RequestHeadersLogEnricher.cs (1)
39
_normalizedHeaders = HeaderNormalizer.PrepareNormalizedHeaderNames(_headersDataClasses,
HttpLoggingTagNames
.RequestHeaderPrefix);
Microsoft.AspNetCore.Diagnostics.Middleware.Tests (104)
Logging\AcceptanceTests.cs (72)
186
Assert.DoesNotContain(state, x => x.Key ==
HttpLoggingTagNames
.RequestBody);
187
Assert.DoesNotContain(state, x => x.Key.StartsWith(
HttpLoggingTagNames
.RequestHeaderPrefix));
188
Assert.DoesNotContain(state, x => x.Key.StartsWith(
HttpLoggingTagNames
.ResponseHeaderPrefix));
189
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Host && !string.IsNullOrEmpty(x.Value));
190
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Path && x.Value == TelemetryConstants.Unknown);
191
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.StatusCode && x.Value == responseStatus);
192
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Method && x.Value == HttpMethod.Post.ToString());
193
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Duration &&
199
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.ResponseBody && x.Value == "Server: hello!Server: world!");
204
Assert.DoesNotContain(state, x => x.Key ==
HttpLoggingTagNames
.ResponseBody);
246
Assert.DoesNotContain(state, x => x.Key ==
HttpLoggingTagNames
.ResponseBody);
247
Assert.DoesNotContain(state, x => x.Key.StartsWith(
HttpLoggingTagNames
.RequestHeaderPrefix));
248
Assert.DoesNotContain(state, x => x.Key.StartsWith(
HttpLoggingTagNames
.ResponseHeaderPrefix));
249
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Host && !string.IsNullOrEmpty(x.Value));
250
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Path && x.Value == TelemetryConstants.Unknown);
251
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.StatusCode && x.Value == responseStatus);
252
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Method && x.Value == HttpMethod.Post.ToString());
253
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Duration &&
259
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.RequestBody && x.Value == Content);
264
Assert.DoesNotContain(state, x => x.Key ==
HttpLoggingTagNames
.RequestBody);
317
Assert.DoesNotContain(requestState, x => x.Key.StartsWith(
HttpLoggingTagNames
.ResponseHeaderPrefix));
318
Assert.DoesNotContain(requestState, x => x.Key ==
HttpLoggingTagNames
.StatusCode);
319
Assert.DoesNotContain(requestState, x => x.Key ==
HttpLoggingTagNames
.Duration);
320
Assert.Single(requestState, x => x.Key ==
HttpLoggingTagNames
.RequestHeaderPrefix + NormalizedRequestHeader);
321
Assert.Single(requestState, x => x.Key ==
HttpLoggingTagNames
.Host && !string.IsNullOrEmpty(x.Value));
322
Assert.Single(requestState, x => x.Key ==
HttpLoggingTagNames
.Path && x.Value == TelemetryConstants.Unknown);
323
Assert.Single(requestState, x => x.Key ==
HttpLoggingTagNames
.Method && x.Value == HttpMethod.Post.ToString());
330
Assert.Single(responseState, x => x.Key ==
HttpLoggingTagNames
.ResponseHeaderPrefix + NormalizedResponseHeader);
331
Assert.Single(responseState, x => x.Key ==
HttpLoggingTagNames
.StatusCode && x.Value == responseStatus);
337
Assert.Single(durationState, x => x.Key ==
HttpLoggingTagNames
.Duration && x.Value != null);
375
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.RequestHeaderPrefix + NormalizedRequestHeader);
376
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.ResponseHeaderPrefix + NormalizedResponseHeader);
377
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Host && !string.IsNullOrEmpty(x.Value));
378
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Path && x.Value == TelemetryConstants.Unknown);
379
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.StatusCode && x.Value == responseStatus);
380
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Duration &&
384
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Method && x.Value == HttpMethod.Get.ToString());
385
Assert.DoesNotContain(state, x => x.Key ==
HttpLoggingTagNames
.RequestBody);
386
Assert.DoesNotContain(state, x => x.Key ==
HttpLoggingTagNames
.ResponseBody);
388
x.Key.StartsWith(
HttpLoggingTagNames
.RequestHeaderPrefix) && !x.Key.EndsWith(NormalizedRequestHeader));
391
x.Key.StartsWith(
HttpLoggingTagNames
.ResponseHeaderPrefix) && !x.Key.EndsWith(NormalizedResponseHeader));
423
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Method && x.Value == HttpMethod.Delete.ToString());
424
Assert.DoesNotContain(state, x => x.Key ==
HttpLoggingTagNames
.RequestBody);
425
Assert.DoesNotContain(state, x => x.Key ==
HttpLoggingTagNames
.ResponseBody);
426
Assert.DoesNotContain(state, x => x.Key.StartsWith(
HttpLoggingTagNames
.RequestHeaderPrefix));
427
Assert.DoesNotContain(state, x => x.Key.StartsWith(
HttpLoggingTagNames
.ResponseHeaderPrefix));
463
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Path && x.Value == RequestPath);
540
Assert.DoesNotContain(firstRecord, x => x.Key ==
HttpLoggingTagNames
.StatusCode);
541
Assert.DoesNotContain(firstRecord, x => x.Key ==
HttpLoggingTagNames
.Duration);
542
Assert.DoesNotContain(secondRecord!, x => x.Key ==
HttpLoggingTagNames
.Duration);
543
Assert.DoesNotContain(fourthRecord, x => x.Key ==
HttpLoggingTagNames
.StatusCode);
544
Assert.DoesNotContain(fourthRecord, x => x.Key ==
HttpLoggingTagNames
.Duration);
545
Assert.DoesNotContain(fithRecord!, x => x.Key ==
HttpLoggingTagNames
.Duration);
549
Assert.Single(secondRecord!, x => x.Key ==
HttpLoggingTagNames
.StatusCode && x.Value == responseStatus);
550
Assert.Single(fithRecord!, x => x.Key ==
HttpLoggingTagNames
.StatusCode && x.Value == responseStatus);
554
Assert.Single(thirdRecord, x => x.Key ==
HttpLoggingTagNames
.Duration && x.Value != null);
555
Assert.Single(sixthRecord, x => x.Key ==
HttpLoggingTagNames
.Duration && x.Value != null);
580
Assert.DoesNotContain(state, x => x.Key.StartsWith(
HttpLoggingTagNames
.RequestHeaderPrefix));
581
Assert.DoesNotContain(state, x => x.Key.StartsWith(
HttpLoggingTagNames
.ResponseHeaderPrefix));
582
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Method && x.Value == HttpMethod.Get.ToString());
583
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Host && !string.IsNullOrEmpty(x.Value));
584
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Path && x.Value == TelemetryConstants.Unknown);
585
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.StatusCode && x.Value == expectedStatus);
586
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Duration &&
621
Assert.DoesNotContain(state, x => x.Key.StartsWith(
HttpLoggingTagNames
.RequestHeaderPrefix));
622
Assert.DoesNotContain(state, x => x.Key.StartsWith(
HttpLoggingTagNames
.ResponseHeaderPrefix));
623
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Method && x.Value == HttpMethod.Put.ToString());
624
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.RequestBody && x.Value == Content);
625
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.ResponseBody && x.Value == "test body");
655
Assert.DoesNotContain(state, x => x.Key.StartsWith(
HttpLoggingTagNames
.RequestHeaderPrefix));
656
Assert.DoesNotContain(state, x => x.Key.StartsWith(
HttpLoggingTagNames
.ResponseHeaderPrefix));
657
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Method && x.Value == HttpMethod.Put.ToString());
Logging\AcceptanceTests.Mvc.cs (24)
81
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Host && !string.IsNullOrEmpty(x.Value));
82
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Path && x.Value == redactedPath);
83
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.StatusCode && x.Value == responseStatus);
84
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Method && x.Value == HttpMethod.Get.ToString());
85
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Duration &&
119
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Host && !string.IsNullOrEmpty(x.Value));
120
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Path && x.Value == ActionRouteTemplate);
121
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.StatusCode && x.Value == responseStatus);
122
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Method && x.Value == HttpMethod.Get.ToString());
123
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Duration &&
170
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Host && !string.IsNullOrEmpty(x.Value));
172
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Path && x.Value == expectedPath);
173
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.StatusCode && x.Value == responseStatus);
174
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Method && x.Value == HttpMethod.Get.ToString());
175
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Duration &&
206
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Host && !string.IsNullOrEmpty(x.Value));
207
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Path && x.Value == $"/api/users/testUserId/someTestData");
208
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.StatusCode && x.Value == responseStatus);
209
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Method && x.Value == HttpMethod.Get.ToString());
210
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Duration &&
249
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Host && !string.IsNullOrEmpty(x.Value));
250
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Path && x.Value == expectedPath);
251
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.StatusCode && x.Value == responseStatus);
252
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Method && x.Value == HttpMethod.Get.ToString());
Logging\AcceptanceTests.Routing.cs (2)
139
Assert.Equal(expectedHttpPath, state[
HttpLoggingTagNames
.Path]);
177
Assert.Equal(httpRoute, state[
HttpLoggingTagNames
.Path]);
Logging\IncomingHttpDimensionsTests.cs (1)
16
var dimensions =
HttpLoggingTagNames
.DimensionNames;
Logging\RequestHeadersEnricherTests.cs (5)
26
private const string NormalizedHeaderKey1 =
HttpLoggingTagNames
.RequestHeaderPrefix + "x-requestid";
27
private const string NormalizedHeaderKey2 =
HttpLoggingTagNames
.RequestHeaderPrefix + "host";
28
private const string NormalizedHeaderKey3 =
HttpLoggingTagNames
.RequestHeaderPrefix + "nullheader";
29
private const string NormalizedHeaderKey4 =
HttpLoggingTagNames
.RequestHeaderPrefix + "x-platform";
188
Assert.False(enrichedState.ContainsKey(
HttpLoggingTagNames
.RequestHeaderPrefix + headerKey2));