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);
83
logContext.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)
230
Assert.DoesNotContain(state, x => x.Key ==
HttpLoggingTagNames
.RequestBody);
231
Assert.DoesNotContain(state, x => x.Key.StartsWith(
HttpLoggingTagNames
.RequestHeaderPrefix));
232
Assert.DoesNotContain(state, x => x.Key.StartsWith(
HttpLoggingTagNames
.ResponseHeaderPrefix));
233
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Host && !string.IsNullOrEmpty(x.Value));
234
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Path && x.Value == TelemetryConstants.Unknown);
235
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.StatusCode && x.Value == responseStatus);
236
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Method && x.Value == HttpMethod.Post.ToString());
237
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Duration &&
243
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.ResponseBody && x.Value == "Server: hello!Server: world!");
248
Assert.DoesNotContain(state, x => x.Key ==
HttpLoggingTagNames
.ResponseBody);
290
Assert.DoesNotContain(state, x => x.Key ==
HttpLoggingTagNames
.ResponseBody);
291
Assert.DoesNotContain(state, x => x.Key.StartsWith(
HttpLoggingTagNames
.RequestHeaderPrefix));
292
Assert.DoesNotContain(state, x => x.Key.StartsWith(
HttpLoggingTagNames
.ResponseHeaderPrefix));
293
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Host && !string.IsNullOrEmpty(x.Value));
294
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Path && x.Value == TelemetryConstants.Unknown);
295
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.StatusCode && x.Value == responseStatus);
296
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Method && x.Value == HttpMethod.Post.ToString());
297
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Duration &&
303
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.RequestBody && x.Value == Content);
308
Assert.DoesNotContain(state, x => x.Key ==
HttpLoggingTagNames
.RequestBody);
343
Assert.DoesNotContain(state, x => x.Key ==
HttpLoggingTagNames
.ResponseBody);
344
Assert.DoesNotContain(state, x => x.Key.StartsWith(
HttpLoggingTagNames
.RequestHeaderPrefix));
345
Assert.DoesNotContain(state, x => x.Key.StartsWith(
HttpLoggingTagNames
.ResponseHeaderPrefix));
346
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Host && !string.IsNullOrEmpty(x.Value));
347
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Path && x.Value == "/myroute/123");
348
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.StatusCode && x.Value == responseStatus);
349
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Method && x.Value == HttpMethod.Post.ToString());
350
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Duration &&
403
Assert.DoesNotContain(requestState, x => x.Key.StartsWith(
HttpLoggingTagNames
.ResponseHeaderPrefix));
404
Assert.DoesNotContain(requestState, x => x.Key ==
HttpLoggingTagNames
.StatusCode);
405
Assert.DoesNotContain(requestState, x => x.Key ==
HttpLoggingTagNames
.Duration);
406
Assert.Single(requestState, x => x.Key ==
HttpLoggingTagNames
.RequestHeaderPrefix + NormalizedRequestHeader);
407
Assert.Single(requestState, x => x.Key ==
HttpLoggingTagNames
.Host && !string.IsNullOrEmpty(x.Value));
408
Assert.Single(requestState, x => x.Key ==
HttpLoggingTagNames
.Path && x.Value == TelemetryConstants.Unknown);
409
Assert.Single(requestState, x => x.Key ==
HttpLoggingTagNames
.Method && x.Value == HttpMethod.Post.ToString());
416
Assert.Single(responseState, x => x.Key ==
HttpLoggingTagNames
.ResponseHeaderPrefix + NormalizedResponseHeader);
417
Assert.Single(responseState, x => x.Key ==
HttpLoggingTagNames
.StatusCode && x.Value == responseStatus);
423
Assert.Single(durationState, x => x.Key ==
HttpLoggingTagNames
.Duration && x.Value != null);
461
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.RequestHeaderPrefix + NormalizedRequestHeader);
462
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.ResponseHeaderPrefix + NormalizedResponseHeader);
463
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Host && !string.IsNullOrEmpty(x.Value));
464
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Path && x.Value == TelemetryConstants.Unknown);
465
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.StatusCode && x.Value == responseStatus);
466
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Duration &&
470
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Method && x.Value == HttpMethod.Get.ToString());
471
Assert.DoesNotContain(state, x => x.Key ==
HttpLoggingTagNames
.RequestBody);
472
Assert.DoesNotContain(state, x => x.Key ==
HttpLoggingTagNames
.ResponseBody);
474
x.Key.StartsWith(
HttpLoggingTagNames
.RequestHeaderPrefix) && !x.Key.EndsWith(NormalizedRequestHeader));
477
x.Key.StartsWith(
HttpLoggingTagNames
.ResponseHeaderPrefix) && !x.Key.EndsWith(NormalizedResponseHeader));
509
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Method && x.Value == HttpMethod.Delete.ToString());
510
Assert.DoesNotContain(state, x => x.Key ==
HttpLoggingTagNames
.RequestBody);
511
Assert.DoesNotContain(state, x => x.Key ==
HttpLoggingTagNames
.ResponseBody);
512
Assert.DoesNotContain(state, x => x.Key.StartsWith(
HttpLoggingTagNames
.RequestHeaderPrefix));
513
Assert.DoesNotContain(state, x => x.Key.StartsWith(
HttpLoggingTagNames
.ResponseHeaderPrefix));
549
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Path && x.Value == RequestPath);
626
Assert.DoesNotContain(firstRecord, x => x.Key ==
HttpLoggingTagNames
.StatusCode);
627
Assert.DoesNotContain(firstRecord, x => x.Key ==
HttpLoggingTagNames
.Duration);
628
Assert.DoesNotContain(secondRecord!, x => x.Key ==
HttpLoggingTagNames
.Duration);
629
Assert.DoesNotContain(fourthRecord, x => x.Key ==
HttpLoggingTagNames
.StatusCode);
630
Assert.DoesNotContain(fourthRecord, x => x.Key ==
HttpLoggingTagNames
.Duration);
631
Assert.DoesNotContain(fithRecord!, x => x.Key ==
HttpLoggingTagNames
.Duration);
635
Assert.Single(secondRecord!, x => x.Key ==
HttpLoggingTagNames
.StatusCode && x.Value == responseStatus);
636
Assert.Single(fithRecord!, x => x.Key ==
HttpLoggingTagNames
.StatusCode && x.Value == responseStatus);
640
Assert.Single(thirdRecord, x => x.Key ==
HttpLoggingTagNames
.Duration && x.Value != null);
641
Assert.Single(sixthRecord, x => x.Key ==
HttpLoggingTagNames
.Duration && x.Value != null);
666
Assert.DoesNotContain(state, x => x.Key.StartsWith(
HttpLoggingTagNames
.RequestHeaderPrefix));
667
Assert.DoesNotContain(state, x => x.Key.StartsWith(
HttpLoggingTagNames
.ResponseHeaderPrefix));
668
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Method && x.Value == HttpMethod.Get.ToString());
669
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Host && !string.IsNullOrEmpty(x.Value));
670
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Path && x.Value == TelemetryConstants.Unknown);
671
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.StatusCode && x.Value == expectedStatus);
672
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Duration &&
707
Assert.DoesNotContain(state, x => x.Key.StartsWith(
HttpLoggingTagNames
.RequestHeaderPrefix));
708
Assert.DoesNotContain(state, x => x.Key.StartsWith(
HttpLoggingTagNames
.ResponseHeaderPrefix));
709
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.Method && x.Value == HttpMethod.Put.ToString());
710
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.RequestBody && x.Value == Content);
711
Assert.Single(state, x => x.Key ==
HttpLoggingTagNames
.ResponseBody && x.Value == "test body");
741
Assert.DoesNotContain(state, x => x.Key.StartsWith(
HttpLoggingTagNames
.RequestHeaderPrefix));
742
Assert.DoesNotContain(state, x => x.Key.StartsWith(
HttpLoggingTagNames
.ResponseHeaderPrefix));
743
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));