186 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)
72
logContext.LoggingFields =
HttpLoggingFields
.None;
77
if (!logContext.IsAnyEnabled(
HttpLoggingFields
.RequestPropertiesAndHeaders))
85
if (logContext.TryDisable(
HttpLoggingFields
.RequestPath))
133
if (logContext.TryDisable(
HttpLoggingFields
.RequestHeaders))
145
if (logContext.TryDisable(
HttpLoggingFields
.ResponseHeaders))
152
|| (!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 (8)
Logging\AcceptanceTests.cs (8)
210
x.LoggingFields |=
HttpLoggingFields
.ResponseBody;
270
x.LoggingFields |=
HttpLoggingFields
.RequestBody;
323
x.LoggingFields |=
HttpLoggingFields
.RequestBody;
368
x.LoggingFields =
HttpLoggingFields
.All;
686
x.LoggingFields |=
HttpLoggingFields
.RequestBody |
HttpLoggingFields
.ResponseBody;
720
static services => services.AddHttpLogging(static x => x.LoggingFields &= ~
HttpLoggingFields
.ResponseBody)
965
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)
126
if (logContext.IsAnyEnabled(
HttpLoggingFields
.RequestBody))
ResponseBufferingStream.cs (1)
128
if (_logContext.LoggingFields.HasFlag(
HttpLoggingFields
.ResponseBody) && _logContext.ResponseBodyLogLimit > 0)
Microsoft.AspNetCore.HttpLogging.Tests (121)
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 (113)
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;
438
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
475
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
511
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
536
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
569
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
604
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
642
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
680
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
719
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
755
options.CurrentValue.LoggingFields =
HttpLoggingFields
.All;
759
context.LoggingFields =
HttpLoggingFields
.None;
773
options.CurrentValue.LoggingFields =
HttpLoggingFields
.None;
778
context.LoggingFields =
HttpLoggingFields
.All;
800
options.CurrentValue.LoggingFields =
HttpLoggingFields
.All;
828
options.CurrentValue.LoggingFields =
HttpLoggingFields
.All;
833
Assert.True(context.TryDisable(
HttpLoggingFields
.RequestPath));
877
options.CurrentValue.LoggingFields =
HttpLoggingFields
.Response;
901
options.CurrentValue.LoggingFields =
HttpLoggingFields
.Duration;
923
options.CurrentValue.LoggingFields =
HttpLoggingFields
.Response;
947
options.CurrentValue.LoggingFields =
HttpLoggingFields
.Response;
973
options.CurrentValue.LoggingFields =
HttpLoggingFields
.ResponseStatusCode;
997
options.CurrentValue.LoggingFields =
HttpLoggingFields
.ResponseHeaders;
1021
options.CurrentValue.LoggingFields =
HttpLoggingFields
.ResponseHeaders;
1041
options.CurrentValue.LoggingFields =
HttpLoggingFields
.ResponseHeaders;
1066
options.CurrentValue.LoggingFields =
HttpLoggingFields
.ResponseBody;
1086
options.CurrentValue.LoggingFields =
HttpLoggingFields
.ResponseBody;
1107
options.CurrentValue.LoggingFields =
HttpLoggingFields
.ResponseBody;
1128
options.CurrentValue.LoggingFields =
HttpLoggingFields
.Response;
1166
options.CurrentValue.LoggingFields =
HttpLoggingFields
.Response;
1203
options.CurrentValue.LoggingFields =
HttpLoggingFields
.ResponseBody;
1229
options.CurrentValue.LoggingFields =
HttpLoggingFields
.ResponseBody;
1249
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
1264
options.CurrentValue.LoggingFields =
HttpLoggingFields
.ResponseStatusCode;
1307
options.CurrentValue.LoggingFields =
HttpLoggingFields
.All;
1368
options.CurrentValue.LoggingFields =
HttpLoggingFields
.ResponseHeaders;
1411
options.CurrentValue.LoggingFields =
HttpLoggingFields
.All ^
HttpLoggingFields
.ResponsePropertiesAndHeaders;
1457
options.CurrentValue.LoggingFields =
HttpLoggingFields
.ResponsePropertiesAndHeaders;
1487
[InlineData(
HttpLoggingFields
.ResponseStatusCode)]
1488
[InlineData(
HttpLoggingFields
.ResponseHeaders)]
1489
public async Task UpgradeToWebSocketLogsWrittenOnlyOnce(
HttpLoggingFields
loggingFields)
1524
[InlineData(
HttpLoggingFields
.ResponseStatusCode)]
1525
[InlineData(
HttpLoggingFields
.ResponseHeaders)]
1526
public async Task OriginalUpgradeFeatureIsRestoredBeforeMiddlewareCompletes(
HttpLoggingFields
loggingFields)
1561
[InlineData(
HttpLoggingFields
.All, true, true)]
1562
[InlineData(
HttpLoggingFields
.All, false, false)]
1563
[InlineData(
HttpLoggingFields
.RequestPropertiesAndHeaders, true, true)]
1564
[InlineData(
HttpLoggingFields
.RequestPropertiesAndHeaders, false, false)]
1565
[InlineData(
HttpLoggingFields
.ResponsePropertiesAndHeaders, true, true)]
1566
[InlineData(
HttpLoggingFields
.ResponsePropertiesAndHeaders, false, false)]
1567
public async Task CombineLogs_OneLog(
HttpLoggingFields
fields, bool hasRequestBody, bool hasResponseBody)
1597
if (fields.HasFlag(
HttpLoggingFields
.RequestPropertiesAndHeaders))
1610
if (fields.HasFlag(
HttpLoggingFields
.ResponsePropertiesAndHeaders))
1619
if (fields.HasFlag(
HttpLoggingFields
.RequestBody) && hasRequestBody)
1624
if (fields.HasFlag(
HttpLoggingFields
.ResponseBody) && hasResponseBody)
1628
if (fields.HasFlag(
HttpLoggingFields
.Duration))
1639
options.CurrentValue.LoggingFields =
HttpLoggingFields
.All;
1676
[InlineData(
HttpLoggingFields
.RequestBody |
HttpLoggingFields
.ResponseBody)]
1677
[InlineData(
HttpLoggingFields
.RequestBody)]
1678
[InlineData(
HttpLoggingFields
.ResponseBody)]
1679
public async Task CombineLogsWithStreamCloseWorks(
HttpLoggingFields
fields)
1726
if (fields.HasFlag(
HttpLoggingFields
.RequestBody))
1734
if (fields.HasFlag(
HttpLoggingFields
.ResponseBody))
1745
options.CurrentValue.LoggingFields =
HttpLoggingFields
.All;
1749
context.LoggingFields =
HttpLoggingFields
.None;
1773
options.CurrentValue.LoggingFields =
HttpLoggingFields
.None;
1778
context.LoggingFields =
HttpLoggingFields
.All;
1801
options.CurrentValue.LoggingFields =
HttpLoggingFields
.All;
1829
options.CurrentValue.LoggingFields =
HttpLoggingFields
.All;
1834
Assert.True(context.TryDisable(
HttpLoggingFields
.ResponseStatusCode));
1873
var app = CreateApp(defaultFields:
HttpLoggingFields
.None);
1920
var app = CreateApp(
HttpLoggingFields
.None, new FakeInterceptor(requestContext =>
1922
Assert.Equal(
HttpLoggingFields
.All, requestContext.LoggingFields);
1923
requestContext.Disable(
HttpLoggingFields
.RequestHeaders);
1927
Assert.Equal(
HttpLoggingFields
.All & ~
HttpLoggingFields
.RequestHeaders, responseContext.LoggingFields);
1928
responseContext.Disable(
HttpLoggingFields
.ResponseHeaders);
1963
var app = CreateApp(defaultFields:
HttpLoggingFields
.None);
2010
var app = CreateApp(
HttpLoggingFields
.None, new FakeInterceptor(requestContext =>
2012
Assert.Equal(
HttpLoggingFields
.All, requestContext.LoggingFields);
2013
requestContext.Disable(
HttpLoggingFields
.RequestHeaders);
2017
Assert.Equal(
HttpLoggingFields
.All & ~
HttpLoggingFields
.RequestHeaders, responseContext.LoggingFields);
2018
responseContext.Disable(
HttpLoggingFields
.ResponseHeaders);
2046
services.AddHttpLogging(o => o.LoggingFields =
HttpLoggingFields
.All);
2137
private IHost CreateApp(
HttpLoggingFields
defaultFields =
HttpLoggingFields
.All, IHttpLoggingInterceptor interceptor = null)
2163
endpoint.MapGet("/attr_responseonly", [HttpLogging(
HttpLoggingFields
.Response)] async (HttpContext c) =>
2173
}).WithHttpLogging(
HttpLoggingFields
.Response);
2175
endpoint.MapGet("/attr_responseandrequest", [HttpLogging(
HttpLoggingFields
.All)] async (HttpContext c) =>
2186
}).WithHttpLogging(
HttpLoggingFields
.All);
2188
endpoint.MapGet("/attr_restrictedheaders", [HttpLogging((
HttpLoggingFields
.Request & ~
HttpLoggingFields
.RequestScheme) | (
HttpLoggingFields
.Response & ~
HttpLoggingFields
.ResponseStatusCode))] async (HttpContext c) =>
2198
}).WithHttpLogging((
HttpLoggingFields
.Request & ~
HttpLoggingFields
.RequestScheme) | (
HttpLoggingFields
.Response & ~
HttpLoggingFields
.ResponseStatusCode));
2200
endpoint.MapGet("/attr_restrictedsize", [HttpLogging(
HttpLoggingFields
.RequestBody |
HttpLoggingFields
.ResponseBody, RequestBodyLogLimit = 3, ResponseBodyLogLimit = 6)] async (HttpContext c) =>
2210
}).WithHttpLogging(
HttpLoggingFields
.RequestBody |
HttpLoggingFields
.ResponseBody, requestBodyLogLimit: 3, responseBodyLogLimit: 6);