Enable raw SQL logging in Entity Framework Core
Figured it out - need to configure DbContext to use logger factory.
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
base.OnConfiguring(optionsBuilder);
optionsBuilder.UseLoggerFactory(_loggerFactory);
}
From MVC Core 2, logging SQL is the default behaviour. Just make sure logging level in appSettings json file is correct.
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}