linq2db / linq2db.EntityFrameworkCore

Bring power of Linq To DB to Entity Framework Core projects
MIT License
462 stars 38 forks source link

Not logging generated sql #38

Closed forik closed 4 years ago

forik commented 4 years ago

Hi, I'm not sure is that by design or not but no sql is being logged. For example, then request to web app starts some of queries are executed using EF Context, and some with linq2db extensions over EF Context, so the latter queries not logged. Probably something needs to be setup?

sdanyliv commented 4 years ago

No, it should be logged automatically if you specify logger for EF Core DbContext. Could you please prepare simple reproduce solution?

forik commented 4 years ago

No, it should be logged automatically if you specify logger for EF Core DbContext. Could you please prepare simple reproduce solution?

I managed to get it working. I'm using Serilog integration and I wasn't explicitly calling UseLoggerFactory on DbContext options builder, so Options property didn't have LoggerFactory. After I added the call everything started to work. Closing.

RouR commented 4 years ago

For anyone who have same issue: Don't foget to call DataConnection.TurnTraceSwitchOn(); https://github.com/linq2db/linq2db/issues/646