I have a console .net application using the entity core. The application uses the logging structure to write to the file and the console:
serviceProvider = new ServiceCollection() .AddLogging() .AddDbContext<DataStoreContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))) .BuildServiceProvider(); //configure console logging serviceProvider.GetService<ILoggerFactory>() .AddConsole(LogLevel.Debug) .AddSerilog(); Log.Logger = new LoggerConfiguration() .MinimumLevel.Information() .WriteTo.RollingFile(Path.Combine(Directory.GetCurrentDirectory(), "logs/vcibot-{Date}.txt")) .WriteTo.RollingFile(Path.Combine(Directory.GetCurrentDirectory(), "logs/vcibot-errors-{Date}.txt"), LogEventLevel.Error) .CreateLogger(); logger = serviceProvider.GetService<ILoggerFactory>() .CreateLogger<Program>();
The minimum level for file output is set to Information. But with this output setup also contains SQL queries, here is an example:
2017-02-06 10: 31: 38.282 -08: 00 [Information] Done by DbCommand (0ms) [Parameters = [], CommandType = 'Text', CommandTimeout = '30 '] SELECT [f]. [BuildIdentifier], [f]. [Branch], [f]. [BuildDate], [f]. [StaticAssetSizeInKb] FROM [FileSizesHistoryEntries] AS [f]
Is there a way to disable SQL query logging (log them only at the debug log level)
source share