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)
63
var
loggingFields = loggingAttribute?.LoggingFields ?? options.LoggingFields;
65
if (_interceptors.Length == 0 && loggingFields ==
HttpLoggingFields
.None)
75
HttpLoggingAttribute? loggingAttribute,
HttpLoggingFields
loggingFields)
114
if (logContext.IsAnyEnabled(
HttpLoggingFields
.RequestPropertiesAndHeaders |
HttpLoggingFields
.RequestQuery))
116
if (loggingFields.HasFlag(
HttpLoggingFields
.RequestProtocol))
121
if (loggingFields.HasFlag(
HttpLoggingFields
.RequestMethod))
126
if (loggingFields.HasFlag(
HttpLoggingFields
.RequestScheme))
131
if (loggingFields.HasFlag(
HttpLoggingFields
.RequestPath))
137
if (loggingFields.HasFlag(
HttpLoggingFields
.RequestQuery))
142
if (loggingFields.HasFlag(
HttpLoggingFields
.RequestHeaders))
157
if (loggingFields.HasFlag(
HttpLoggingFields
.RequestBody))
192
if (logContext.IsAnyEnabled(
HttpLoggingFields
.ResponsePropertiesAndHeaders))
206
if (loggingFields.HasFlag(
HttpLoggingFields
.ResponseBody) || _interceptors.Length > 0)
234
if (logContext.IsAnyEnabled(
HttpLoggingFields
.Duration))
236
logContext.AddParameter(nameof(
HttpLoggingFields
.Duration), logContext.GetDuration());
262
if (logContext.IsAnyEnabled(
HttpLoggingFields
.Duration))
336
var
loggingFields = logContext.LoggingFields;
339
if (loggingFields.HasFlag(
HttpLoggingFields
.ResponseStatusCode))
344
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)
171
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)
121
options.CurrentValue.LoggingFields =
HttpLoggingFields
.None;
165
options.CurrentValue.LoggingFields =
HttpLoggingFields
.Request;
197
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestProperties;
229
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestHeaders;
310
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
328
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
359
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
387
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
415
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
455
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
492
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
528
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
553
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
586
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
621
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
659
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
697
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
736
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
772
options.CurrentValue.LoggingFields =
HttpLoggingFields
.All;
776
context.LoggingFields =
HttpLoggingFields
.None;
790
options.CurrentValue.LoggingFields =
HttpLoggingFields
.None;
795
context.LoggingFields =
HttpLoggingFields
.All;
817
options.CurrentValue.LoggingFields =
HttpLoggingFields
.All;
845
options.CurrentValue.LoggingFields =
HttpLoggingFields
.All;
850
Assert.True(context.TryDisable(
HttpLoggingFields
.RequestPath));
894
options.CurrentValue.LoggingFields =
HttpLoggingFields
.Response;
918
options.CurrentValue.LoggingFields =
HttpLoggingFields
.Duration;
940
options.CurrentValue.LoggingFields =
HttpLoggingFields
.Response;
964
options.CurrentValue.LoggingFields =
HttpLoggingFields
.Response;
990
options.CurrentValue.LoggingFields =
HttpLoggingFields
.ResponseStatusCode;
1014
options.CurrentValue.LoggingFields =
HttpLoggingFields
.ResponseHeaders;
1038
options.CurrentValue.LoggingFields =
HttpLoggingFields
.ResponseHeaders;
1058
options.CurrentValue.LoggingFields =
HttpLoggingFields
.ResponseHeaders;
1083
options.CurrentValue.LoggingFields =
HttpLoggingFields
.ResponseBody;
1103
options.CurrentValue.LoggingFields =
HttpLoggingFields
.ResponseBody;
1124
options.CurrentValue.LoggingFields =
HttpLoggingFields
.ResponseBody;
1145
options.CurrentValue.LoggingFields =
HttpLoggingFields
.Response;
1183
options.CurrentValue.LoggingFields =
HttpLoggingFields
.Response;
1220
options.CurrentValue.LoggingFields =
HttpLoggingFields
.ResponseBody;
1246
options.CurrentValue.LoggingFields =
HttpLoggingFields
.ResponseBody;
1266
options.CurrentValue.LoggingFields =
HttpLoggingFields
.RequestBody;
1281
options.CurrentValue.LoggingFields =
HttpLoggingFields
.ResponseStatusCode;
1324
options.CurrentValue.LoggingFields =
HttpLoggingFields
.All;
1385
options.CurrentValue.LoggingFields =
HttpLoggingFields
.ResponseHeaders;
1428
options.CurrentValue.LoggingFields =
HttpLoggingFields
.All ^
HttpLoggingFields
.ResponsePropertiesAndHeaders;
1474
options.CurrentValue.LoggingFields =
HttpLoggingFields
.ResponsePropertiesAndHeaders;
1504
[InlineData(
HttpLoggingFields
.ResponseStatusCode)]
1505
[InlineData(
HttpLoggingFields
.ResponseHeaders)]
1506
public async Task UpgradeToWebSocketLogsWrittenOnlyOnce(
HttpLoggingFields
loggingFields)
1541
[InlineData(
HttpLoggingFields
.ResponseStatusCode)]
1542
[InlineData(
HttpLoggingFields
.ResponseHeaders)]
1543
public async Task OriginalUpgradeFeatureIsRestoredBeforeMiddlewareCompletes(
HttpLoggingFields
loggingFields)
1578
[InlineData(
HttpLoggingFields
.All, true, true)]
1579
[InlineData(
HttpLoggingFields
.All, false, false)]
1580
[InlineData(
HttpLoggingFields
.RequestPropertiesAndHeaders, true, true)]
1581
[InlineData(
HttpLoggingFields
.RequestPropertiesAndHeaders, false, false)]
1582
[InlineData(
HttpLoggingFields
.ResponsePropertiesAndHeaders, true, true)]
1583
[InlineData(
HttpLoggingFields
.ResponsePropertiesAndHeaders, false, false)]
1584
public async Task CombineLogs_OneLog(
HttpLoggingFields
fields, bool hasRequestBody, bool hasResponseBody)
1614
if (fields.HasFlag(
HttpLoggingFields
.RequestPropertiesAndHeaders))
1627
if (fields.HasFlag(
HttpLoggingFields
.ResponsePropertiesAndHeaders))
1636
if (fields.HasFlag(
HttpLoggingFields
.RequestBody) && hasRequestBody)
1641
if (fields.HasFlag(
HttpLoggingFields
.ResponseBody) && hasResponseBody)
1645
if (fields.HasFlag(
HttpLoggingFields
.Duration))
1656
options.CurrentValue.LoggingFields =
HttpLoggingFields
.All;
1693
[InlineData(
HttpLoggingFields
.RequestBody |
HttpLoggingFields
.ResponseBody)]
1694
[InlineData(
HttpLoggingFields
.RequestBody)]
1695
[InlineData(
HttpLoggingFields
.ResponseBody)]
1696
public async Task CombineLogsWithStreamCloseWorks(
HttpLoggingFields
fields)
1743
if (fields.HasFlag(
HttpLoggingFields
.RequestBody))
1751
if (fields.HasFlag(
HttpLoggingFields
.ResponseBody))
1762
options.CurrentValue.LoggingFields =
HttpLoggingFields
.All;
1766
context.LoggingFields =
HttpLoggingFields
.None;
1790
options.CurrentValue.LoggingFields =
HttpLoggingFields
.None;
1795
context.LoggingFields =
HttpLoggingFields
.All;
1818
options.CurrentValue.LoggingFields =
HttpLoggingFields
.All;
1846
options.CurrentValue.LoggingFields =
HttpLoggingFields
.All;
1851
Assert.True(context.TryDisable(
HttpLoggingFields
.ResponseStatusCode));
1890
var app = CreateApp(defaultFields:
HttpLoggingFields
.None);
1937
var app = CreateApp(
HttpLoggingFields
.None, new FakeInterceptor(requestContext =>
1939
Assert.Equal(
HttpLoggingFields
.All, requestContext.LoggingFields);
1940
requestContext.Disable(
HttpLoggingFields
.RequestHeaders);
1944
Assert.Equal(
HttpLoggingFields
.All & ~
HttpLoggingFields
.RequestHeaders, responseContext.LoggingFields);
1945
responseContext.Disable(
HttpLoggingFields
.ResponseHeaders);
1980
var app = CreateApp(defaultFields:
HttpLoggingFields
.None);
2027
var app = CreateApp(
HttpLoggingFields
.None, new FakeInterceptor(requestContext =>
2029
Assert.Equal(
HttpLoggingFields
.All, requestContext.LoggingFields);
2030
requestContext.Disable(
HttpLoggingFields
.RequestHeaders);
2034
Assert.Equal(
HttpLoggingFields
.All & ~
HttpLoggingFields
.RequestHeaders, responseContext.LoggingFields);
2035
responseContext.Disable(
HttpLoggingFields
.ResponseHeaders);
2063
services.AddHttpLogging(o => o.LoggingFields =
HttpLoggingFields
.All);
2155
private IHost CreateApp(
HttpLoggingFields
defaultFields =
HttpLoggingFields
.All, IHttpLoggingInterceptor interceptor = null)
2181
endpoint.MapGet("/attr_responseonly", [HttpLogging(
HttpLoggingFields
.Response)] async (HttpContext c) =>
2191
}).WithHttpLogging(
HttpLoggingFields
.Response);
2193
endpoint.MapGet("/attr_responseandrequest", [HttpLogging(
HttpLoggingFields
.All)] async (HttpContext c) =>
2204
}).WithHttpLogging(
HttpLoggingFields
.All);
2206
endpoint.MapGet("/attr_restrictedheaders", [HttpLogging((
HttpLoggingFields
.Request & ~
HttpLoggingFields
.RequestScheme) | (
HttpLoggingFields
.Response & ~
HttpLoggingFields
.ResponseStatusCode))] async (HttpContext c) =>
2216
}).WithHttpLogging((
HttpLoggingFields
.Request & ~
HttpLoggingFields
.RequestScheme) | (
HttpLoggingFields
.Response & ~
HttpLoggingFields
.ResponseStatusCode));
2218
endpoint.MapGet("/attr_restrictedsize", [HttpLogging(
HttpLoggingFields
.RequestBody |
HttpLoggingFields
.ResponseBody, RequestBodyLogLimit = 3, ResponseBodyLogLimit = 6)] async (HttpContext c) =>
2228
}).WithHttpLogging(
HttpLoggingFields
.RequestBody |
HttpLoggingFields
.ResponseBody, requestBodyLogLimit: 3, responseBodyLogLimit: 6);