By default logging inside XUnit can be done through the ITestOutputHelper. But this is only useful in situations where you are inside in your test code and have direct access to this interface.
Most of the logging in your application however, is typically happening inside the application logic itself(through the ILogger<T>
Luckily we don't have to create such a solution ourselves, but can use one of the available open source projects that solve exactly this issue. I decided to give MartinCostello.Logging.XUnit a try.
Installation
To install it, just add is as a Nuget package to your XUnit test project:
dotnet add package MartinCostello.Logging.XUnit
Usage
To use, it you should register the adapter as your ILogger in Microsoft DI container:
Remark: I first had a look at Divergic.Logging.Xunit but it wasn't so easy to integrate it as part of my application. bootstrapping logic.