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