176 references to HttpLoggingFields
HttpLogging.Sample (7)
SampleHttpLoggingInterceptor.cs (6)
15
logContext.LoggingFields =
HttpLoggingFields
.None;
19
if (!logContext.IsAnyEnabled(
HttpLoggingFields
.Request))
24
if (logContext.TryDisable(
HttpLoggingFields
.RequestPath))
29
if (logContext.TryDisable(
HttpLoggingFields
.RequestHeaders))
58
if (!logContext.IsAnyEnabled(
HttpLoggingFields
.Response))
63
if (logContext.TryDisable(
HttpLoggingFields
.ResponseHeaders))
Startup.cs (1)
16
logging.LoggingFields =
HttpLoggingFields
.All;
Microsoft.AspNetCore.Diagnostics.Middleware (8)
Logging\HttpLoggingRedactionInterceptor.cs (6)
70
logContext.LoggingFields =
HttpLoggingFields
.None;
75
if (!logContext.IsAnyEnabled(
HttpLoggingFields
.RequestPropertiesAndHeaders))
83
if (logContext.TryDisable(
HttpLoggingFields
.RequestPath))
127
if (logContext.TryDisable(
HttpLoggingFields
.RequestHeaders))
139
if (logContext.TryDisable(
HttpLoggingFields
.ResponseHeaders))
146
|| (!logContext.IsAnyEnabled(
HttpLoggingFields
.Response) && logContext.Parameters.Count == 0))
Logging\HttpLoggingServiceCollectionExtensions.cs (2)
28
/// This will enable <see cref="HttpLoggingOptions.CombineLogs"/> and <see cref="
HttpLoggingFields
.Duration"/> by default.
45
o.LoggingFields |=
HttpLoggingFields
.Duration;
Microsoft.AspNetCore.Diagnostics.Middleware.Tests (7)
Logging\AcceptanceTests.cs (7)
166
x.LoggingFields |=
HttpLoggingFields
.ResponseBody;
226
x.LoggingFields |=
HttpLoggingFields
.RequestBody;
282
x.LoggingFields =
HttpLoggingFields
.All;
600
x.LoggingFields |=
HttpLoggingFields
.RequestBody |
HttpLoggingFields
.ResponseBody;
634
static services => services.AddHttpLogging(static x => x.LoggingFields &= ~
HttpLoggingFields
.ResponseBody)
726
o.LoggingFields =
HttpLoggingFields
.None;
Microsoft.AspNetCore.HttpLogging (42)
HttpLoggingAttribute.cs (2)
16
public HttpLoggingAttribute(
HttpLoggingFields
loggingFields)
27
public
HttpLoggingFields
LoggingFields { get; }
HttpLoggingEndpointConventionBuilderExtensions.cs (2)
18
/// <param name="loggingFields">The <see cref="
HttpLoggingFields
"/> to apply to this endpoint.</param>
23
public static TBuilder WithHttpLogging<TBuilder>(this TBuilder builder,
HttpLoggingFields
loggingFields, int? requestBodyLogLimit = null, int? responseBodyLogLimit = null) where TBuilder : IEndpointConventionBuilder
HttpLoggingInterceptorContext.cs (11)
15
/// <see cref="HttpLoggingEndpointConventionBuilderExtensions.WithHttpLogging{TBuilder}(TBuilder,
HttpLoggingFields
, int?, int?)" />.
45
/// <see cref="HttpLoggingEndpointConventionBuilderExtensions.WithHttpLogging{TBuilder}(TBuilder,
HttpLoggingFields
, int?, int?)"/>.
47
public
HttpLoggingFields
LoggingFields { get; set; }
55
/// <see cref="HttpLoggingEndpointConventionBuilderExtensions.WithHttpLogging{TBuilder}(TBuilder,
HttpLoggingFields
, int?, int?)"/>.
65
/// <see cref="HttpLoggingEndpointConventionBuilderExtensions.WithHttpLogging{TBuilder}(TBuilder,
HttpLoggingFields
, int?, int?)"/>.
97
public void Enable(
HttpLoggingFields
fields)
106
public bool IsAnyEnabled(
HttpLoggingFields
fields)
108
return (LoggingFields & fields) !=
HttpLoggingFields
.None;
115
public void Disable(
HttpLoggingFields
fields)
125
public bool TryDisable(
HttpLoggingFields
fields)
139
LoggingFields =
HttpLoggingFields
.None;
HttpLoggingMiddleware.cs (20)
59
var
loggingFields = loggingAttribute?.LoggingFields ?? options.LoggingFields;
61
if (_interceptors.Length == 0 && loggingFields ==
HttpLoggingFields
.None)
71
HttpLoggingAttribute? loggingAttribute,
HttpLoggingFields
loggingFields)
110
if (logContext.IsAnyEnabled(
HttpLoggingFields
.RequestPropertiesAndHeaders |
HttpLoggingFields
.RequestQuery))
112
if (loggingFields.HasFlag(
HttpLoggingFields
.RequestProtocol))
117
if (loggingFields.HasFlag(
HttpLoggingFields
.RequestMethod))
122
if (loggingFields.HasFlag(
HttpLoggingFields
.RequestScheme))
127
if (loggingFields.HasFlag(
HttpLoggingFields
.RequestPath))
133
if (loggingFields.HasFlag(
HttpLoggingFields
.RequestQuery))
138
if (loggingFields.HasFlag(
HttpLoggingFields
.RequestHeaders))
153
if (loggingFields.HasFlag(
HttpLoggingFields
.RequestBody))
188
if (logContext.IsAnyEnabled(
HttpLoggingFields
.ResponsePropertiesAndHeaders))
202
if (loggingFields.HasFlag(
HttpLoggingFields
.ResponseBody) || _interceptors.Length > 0)
231
if (logContext.IsAnyEnabled(
HttpLoggingFields
.Duration))
233
logContext.AddParameter(nameof(
HttpLoggingFields
.Duration), logContext.GetDuration());
259
if (logContext.IsAnyEnabled(
HttpLoggingFields
.Duration))
330
var
loggingFields = logContext.LoggingFields;
333
if (loggingFields.HasFlag(
HttpLoggingFields
.ResponseStatusCode))
338
if (loggingFields.HasFlag(
HttpLoggingFields
.ResponseHeaders))
HttpLoggingOptions.cs (3)
16
public
HttpLoggingFields
LoggingFields { get; set; } =
HttpLoggingFields
.RequestPropertiesAndHeaders |
HttpLoggingFields
.ResponsePropertiesAndHeaders;
IHttpLoggingInterceptor.cs (2)
33
/// and be logged together. <see cref="
HttpLoggingFields
.RequestBody"/> and <see cref="
HttpLoggingFields
.ResponseBody"/> can also be disabled in OnResponseAsync to prevent
RequestBufferingStream.cs (1)
125
if (logContext.IsAnyEnabled(
HttpLoggingFields
.RequestBody))
ResponseBufferingStream.cs (1)
126
if (_logContext.LoggingFields.HasFlag(
HttpLoggingFields
.ResponseBody) && _logContext.ResponseBodyLogLimit > 0)
Microsoft.AspNetCore.HttpLogging.Tests (112)
HttpLoggingAttributeTests.cs (3)
11
var ex = Assert.Throws<ArgumentOutOfRangeException>(() => new HttpLoggingAttribute(
HttpLoggingFields
.None) { RequestBodyLogLimit = -1 });
14
ex = Assert.Throws<ArgumentOutOfRangeException>(() => new HttpLoggingAttribute(
HttpLoggingFields
.None) { ResponseBodyLogLimit = -1 });
21
var attribute = new HttpLoggingAttribute(
HttpLoggingFields
.None);
HttpLoggingEndpointConventionBuilderTests.cs (5)
16
var
loggingFields =
HttpLoggingFields
.RequestScheme |
HttpLoggingFields
.RequestPath;
45
testConventionBuilder.WithHttpLogging(
HttpLoggingFields
.None, requestBodyLogLimit: -1));
49
testConventionBuilder.WithHttpLogging(
HttpLoggingFields
.None, responseBodyLogLimit: -1));
HttpLoggingMiddlewareTests.cs (104)
104
options.CurrentValue.LoggingFields =
HttpLoggingFields
.None;
148
options.CurrentValue.LoggingFields =
HttpLoggingFields
.Request;
180
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestProperties;
212
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestHeaders;
293
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
311
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
342
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
370
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
398
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
435
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
471
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
496
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
529
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
564
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
602
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
640
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
679
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
715
options.CurrentValue.LoggingFields =
HttpLoggingFields
.All;
719
context.LoggingFields =
HttpLoggingFields
.None;
733
options.CurrentValue.LoggingFields =
HttpLoggingFields
.None;
738
context.LoggingFields =
HttpLoggingFields
.All;
760
options.CurrentValue.LoggingFields =
HttpLoggingFields
.All;
788
options.CurrentValue.LoggingFields =
HttpLoggingFields
.All;
793
Assert.True(context.TryDisable(
HttpLoggingFields
.RequestPath));
837
options.CurrentValue.LoggingFields =
HttpLoggingFields
.Response;
861
options.CurrentValue.LoggingFields =
HttpLoggingFields
.Duration;
883
options.CurrentValue.LoggingFields =
HttpLoggingFields
.Response;
907
options.CurrentValue.LoggingFields =
HttpLoggingFields
.Response;
933
options.CurrentValue.LoggingFields =
HttpLoggingFields
.ResponseStatusCode;
957
options.CurrentValue.LoggingFields =
HttpLoggingFields
.ResponseHeaders;
981
options.CurrentValue.LoggingFields =
HttpLoggingFields
.ResponseHeaders;
1001
options.CurrentValue.LoggingFields =
HttpLoggingFields
.ResponseHeaders;
1026
options.CurrentValue.LoggingFields =
HttpLoggingFields
.ResponseBody;
1046
options.CurrentValue.LoggingFields =
HttpLoggingFields
.ResponseBody;
1067
options.CurrentValue.LoggingFields =
HttpLoggingFields
.ResponseBody;
1088
options.CurrentValue.LoggingFields =
HttpLoggingFields
.Response;
1126
options.CurrentValue.LoggingFields =
HttpLoggingFields
.Response;
1163
options.CurrentValue.LoggingFields =
HttpLoggingFields
.ResponseBody;
1183
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
1198
options.CurrentValue.LoggingFields =
HttpLoggingFields
.ResponseStatusCode;
1241
options.CurrentValue.LoggingFields =
HttpLoggingFields
.All;
1302
options.CurrentValue.LoggingFields =
HttpLoggingFields
.ResponseHeaders;
1345
options.CurrentValue.LoggingFields =
HttpLoggingFields
.All ^
HttpLoggingFields
.ResponsePropertiesAndHeaders;
1391
options.CurrentValue.LoggingFields =
HttpLoggingFields
.ResponsePropertiesAndHeaders;
1421
[InlineData(
HttpLoggingFields
.ResponseStatusCode)]
1422
[InlineData(
HttpLoggingFields
.ResponseHeaders)]
1423
public async Task UpgradeToWebSocketLogsWrittenOnlyOnce(
HttpLoggingFields
loggingFields)
1458
[InlineData(
HttpLoggingFields
.ResponseStatusCode)]
1459
[InlineData(
HttpLoggingFields
.ResponseHeaders)]
1460
public async Task OriginalUpgradeFeatureIsRestoredBeforeMiddlewareCompletes(
HttpLoggingFields
loggingFields)
1495
[InlineData(
HttpLoggingFields
.All, true, true)]
1496
[InlineData(
HttpLoggingFields
.All, false, false)]
1497
[InlineData(
HttpLoggingFields
.RequestPropertiesAndHeaders, true, true)]
1498
[InlineData(
HttpLoggingFields
.RequestPropertiesAndHeaders, false, false)]
1499
[InlineData(
HttpLoggingFields
.ResponsePropertiesAndHeaders, true, true)]
1500
[InlineData(
HttpLoggingFields
.ResponsePropertiesAndHeaders, false, false)]
1501
public async Task CombineLogs_OneLog(
HttpLoggingFields
fields, bool hasRequestBody, bool hasResponseBody)
1531
if (fields.HasFlag(
HttpLoggingFields
.RequestPropertiesAndHeaders))
1544
if (fields.HasFlag(
HttpLoggingFields
.ResponsePropertiesAndHeaders))
1553
if (fields.HasFlag(
HttpLoggingFields
.RequestBody) && hasRequestBody)
1558
if (fields.HasFlag(
HttpLoggingFields
.ResponseBody) && hasResponseBody)
1562
if (fields.HasFlag(
HttpLoggingFields
.Duration))
1573
options.CurrentValue.LoggingFields =
HttpLoggingFields
.All;
1613
options.CurrentValue.LoggingFields =
HttpLoggingFields
.All;
1617
context.LoggingFields =
HttpLoggingFields
.None;
1641
options.CurrentValue.LoggingFields =
HttpLoggingFields
.None;
1646
context.LoggingFields =
HttpLoggingFields
.All;
1669
options.CurrentValue.LoggingFields =
HttpLoggingFields
.All;
1697
options.CurrentValue.LoggingFields =
HttpLoggingFields
.All;
1702
Assert.True(context.TryDisable(
HttpLoggingFields
.ResponseStatusCode));
1741
var app = CreateApp(defaultFields:
HttpLoggingFields
.None);
1788
var app = CreateApp(
HttpLoggingFields
.None, new FakeInterceptor(requestContext =>
1790
Assert.Equal(
HttpLoggingFields
.All, requestContext.LoggingFields);
1791
requestContext.Disable(
HttpLoggingFields
.RequestHeaders);
1795
Assert.Equal(
HttpLoggingFields
.All & ~
HttpLoggingFields
.RequestHeaders, responseContext.LoggingFields);
1796
responseContext.Disable(
HttpLoggingFields
.ResponseHeaders);
1831
var app = CreateApp(defaultFields:
HttpLoggingFields
.None);
1878
var app = CreateApp(
HttpLoggingFields
.None, new FakeInterceptor(requestContext =>
1880
Assert.Equal(
HttpLoggingFields
.All, requestContext.LoggingFields);
1881
requestContext.Disable(
HttpLoggingFields
.RequestHeaders);
1885
Assert.Equal(
HttpLoggingFields
.All & ~
HttpLoggingFields
.RequestHeaders, responseContext.LoggingFields);
1886
responseContext.Disable(
HttpLoggingFields
.ResponseHeaders);
1914
services.AddHttpLogging(o => o.LoggingFields =
HttpLoggingFields
.All);
2005
private IHost CreateApp(
HttpLoggingFields
defaultFields =
HttpLoggingFields
.All, IHttpLoggingInterceptor interceptor = null)
2031
endpoint.MapGet("/attr_responseonly", [HttpLogging(
HttpLoggingFields
.Response)] async (HttpContext c) =>
2041
}).WithHttpLogging(
HttpLoggingFields
.Response);
2043
endpoint.MapGet("/attr_responseandrequest", [HttpLogging(
HttpLoggingFields
.All)] async (HttpContext c) =>
2054
}).WithHttpLogging(
HttpLoggingFields
.All);
2056
endpoint.MapGet("/attr_restrictedheaders", [HttpLogging((
HttpLoggingFields
.Request & ~
HttpLoggingFields
.RequestScheme) | (
HttpLoggingFields
.Response & ~
HttpLoggingFields
.ResponseStatusCode))] async (HttpContext c) =>
2066
}).WithHttpLogging((
HttpLoggingFields
.Request & ~
HttpLoggingFields
.RequestScheme) | (
HttpLoggingFields
.Response & ~
HttpLoggingFields
.ResponseStatusCode));
2068
endpoint.MapGet("/attr_restrictedsize", [HttpLogging(
HttpLoggingFields
.RequestBody |
HttpLoggingFields
.ResponseBody, RequestBodyLogLimit = 3, ResponseBodyLogLimit = 6)] async (HttpContext c) =>
2078
}).WithHttpLogging(
HttpLoggingFields
.RequestBody |
HttpLoggingFields
.ResponseBody, requestBodyLogLimit: 3, responseBodyLogLimit: 6);