Using the guide here, I\'m trying to log the SQL generated by my MVC web application.
The guide uses the line:
context.Database.Log = Console.Write;
To write your logs to a file, try this:
using (var context = new MyDbContext()) { var logFile = new StreamWriter("C:\\temp\\log.txt"); context.Database.Log = logFile.Write; // Execute your queries here // .... logFile.Close(); }