In the past I have seen clear printouts of the SQL statements from Entity Framework sent to the logger, historically by setting DbContext.Database.Log
. Things seem to have changed and I can't get them to work.
This page by MS implies that configuring logging for ASP.NET Core automatically configures entity logging. Following this I have configured the logging using the appsettings.json
file as below:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"System": "Information",
"Microsoft": "Information",
"Microsoft.EntityFrameworkCore": "Debug",
}
}
}
This does result in lots of logs from the Entity Framework Core showing up, however none of them are the queries. I would expect to see entries from Microsoft.EntityFrameworkCore.Database.Command
but I do not. How do I get the SQL statements in the logs?
I know this looks similar to a few other questions, but none of them helped me out.
this is the one I stole out of Adam Freeman's Pro Entity Framework Core 2 book and I see the sql statements
{
"Logging":{
"LogLevel": {
"Default": "None",
"Microsoft.EntityFrameworkCore": "Information"
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.