How to log SQL generated by EF using log4net
问题 In my web project I'm using EF6 and I'd like to log generated SQL for debugging purpose. I'm also using log4net to handle logs, so I'm looking for a way to integrate them together. What's the correct way to achieve this? 回答1: At the moment I'm using this approach: in my BaseController I have something like this: public class BaseController { protected MyDbContext DataContext { get; set; } protected readonly ILog logger; public BaseController() { DataContext = new MyDbContext(); logger =