-
Notifications
You must be signed in to change notification settings - Fork 168
Closed
Description
Type of issue
Missing information
Description
The docs don't mention how to get logs out of tests. There is a very brief comment that shows up in the xunit code sample, but it doesn't show for other frameworks
// To output logs to the xUnit.net ITestOutputHelper,
// consider adding a package from https://www.nuget.org/packages?q=xunit+loggingIt took me quite a while to work out that I was meant to use the AddLogging method on the services, and even longer to work out I needed to configure some default log filters as the appsettings.json from the application under test wasn't being replicated into the test projects.
appHost.Services.AddLogging(x => x
.AddNUnit() // https://www.nuget.org/packages/Extensions.Logging.NUnit
.AddFilter("Default", LogLevel.Information)
.AddFilter("Microsoft.AspNetCore", LogLevel.Warning)
.AddFilter("Aspire.Hosting.Dcp", LogLevel.Warning)
);Page URL
https://learn.microsoft.com/en-us/dotnet/aspire/testing/write-your-first-test
Content source URL
Document Version Independent Id
493680b6-598d-1d8c-6e0e-f54286ae77e0
Article author
IEvangelist, sandord, hwoodiwiss and v-bohatikovItzaliveCopilot
Metadata
Metadata
Assignees
Labels
No labels