Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -900,14 +900,10 @@ await RunAsync<TestStartup>(
services => services
.AddLogging(builder =>
{
// enable Microsoft.AspNetCore.Routing.Matching.DfaMatcher debug logs
// which are produced by ASP.NET Core within HTTP context.
// This is what is going to be buffered and tested.
builder.AddFilter("Microsoft.AspNetCore.Routing.Matching.DfaMatcher", LogLevel.Debug);

// Disable logs from HTTP logging middleware, otherwise even though they are not buffered,
// they will be logged as usual and contaminate test results:
builder.AddFilter("Microsoft.AspNetCore.HttpLogging", LogLevel.None);
// Disable logs from all ASP.NET Core infrastructure, otherwise they
// will contaminate test results:
builder.AddFilter("Microsoft.AspNetCore", LogLevel.None);
builder.AddFilter("Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware", LogLevel.None);

builder.AddPerIncomingRequestBuffer(options =>
{
Expand Down Expand Up @@ -944,10 +940,10 @@ await RunAsync<TestStartup>(
logger.LogTrace($"This is a huge log message 3, {hugeState}");
await WaitForLogRecordsAsync(logCollector, _defaultLogTimeout);

// 1st log record is from DfaMatcher,
// 2, 3, 4th are from our "test" category
// and 5 and 6th are logs from the /logatrequest endpoint
Assert.Equal(6, logCollector.Count);
// 1st is the flushed Trace from "test" category
// 2, 3rd are unbuffered logs from our "test" category
// and 4 and 5th are logs from the /logatrequest endpoint
Comment thread
stephentoub marked this conversation as resolved.
Outdated
Assert.Equal(5, logCollector.Count);
Assert.Equal(LogLevel.Trace, logCollector.LatestRecord.Level);
Assert.Equal("test", logCollector.LatestRecord.Category);
});
Expand Down
Loading