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;
Using a delegate allows you to do write any function taking a string. As a very simple logging to a file, you could do the following:
context.Database.Log = message => File.AppendText("C:\\mylog.txt").WriteLine(message);
In a web environment, you may wish to use Trace to log this information:
context.Database.Log = message => Trace.WriteLine(message);
You can see more examples of using delegates on the MSDN page on Anonymous Functions.