// ReSharper disable once ParameterOnlyUsedForPreconditionCheck.Local private void FilterTest(Func <string, bool> filter, params string[] expected) { var loggerFactory = new ListLoggerFactory(filter); var dbLogger = new DiagnosticsLogger <DbLoggerCategory.Database>( loggerFactory, new LoggingOptions(), new DiagnosticListener("Fake"), new TestLoggingDefinitions(), new NullDbContextLogger()); var sqlLogger = new DiagnosticsLogger <DbLoggerCategory.Database.Command>( loggerFactory, new LoggingOptions(), new DiagnosticListener("Fake"), new TestLoggingDefinitions(), new NullDbContextLogger()); var queryLogger = new DiagnosticsLogger <DbLoggerCategory.Query>( loggerFactory, new LoggingOptions(), new DiagnosticListener("Fake"), new TestLoggingDefinitions(), new NullDbContextLogger()); var randomLogger = loggerFactory.CreateLogger("Random"); dbLogger.Logger.LogInformation(1, "DB1"); sqlLogger.Logger.LogInformation(2, "SQL1"); queryLogger.Logger.LogInformation(3, "Query1"); randomLogger.LogInformation(4, "Random1"); dbLogger.Logger.LogInformation(1, "DB2"); sqlLogger.Logger.LogInformation(2, "SQL2"); queryLogger.Logger.LogInformation(3, "Query2"); randomLogger.LogInformation(4, "Random2"); Assert.Equal(expected, loggerFactory.Log.Select(l => l.Message)); }