I'm using EF Core 2.2.4 and am trying to figure out which SQL statements EF Core is sending to our SQLite database in our unit tests. Since we're using xUnit (2.4.1), we have to write log messages to the ITestOutputHelper instance xUnit is injecting into our test classes instead of the console. For the console, I have found this code:
private static ILoggerFactory GetLoggerFactory()
{
IServiceCollection serviceCollection = new ServiceCollection();
serviceCollection.AddLogging(builder =>
builder.AddConsole()
.AddFilter(DbLoggerCategory.Database.Command.Name,
LogLevel.Information));
return serviceCollection.BuildServiceProvider()
.GetService<ILoggerFactory>();
}
What do I have to do to redirect this output to ITestOutputHelper.WriteLine()?