After upgrading to asp.net + entity framework core 2 i noticed something weird. Before (in 1.1), i had to use DbContextOptionsBuilder.UseLoggerFactory to log SQL queries that were produced by ef, but now, i don't have to do it anymore, SQL queries are logged by default.
The logger factory is set to "Information"
loggerFactory.AddFile("Logs/MyApp-{Hour}.txt", LogLevel.Information);
Shouldn't SQL queries be associated with Debug? is it normal? is there a way to keep the logging level Information and disabling just the SQL logging?
I found out that entity framework is supposed to log SQL in "Information" I changed the loggerFactory to
loggerFactory.AddFile("Logs/MyApp-{Hour}.txt", LogLevel.Information, new Dictionary<string, LogLevel>()
{
{ "Microsoft", LogLevel.Error },
{ "System", LogLevel.Error }
});
So that everything with "Microsoft" or "System" in it's namespace would log only Errors (or anything above)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With