LINQ to SQL log to debug window, file, memory or multiple writers
- π
- π 721 words
- π 4 minutes
- π¦ .NET
- π·οΈ C#, LINQ, debugging
- π¬ 7 responses
The Log property on a LINQ to SQL data context takes a TextWriter and streams out details of the SQL statements and parameters that are being generated and sent to the server.
Normally in examples you will see Console.Out being assigned to it which is fine for small demos and sandboxes but sooner or later youβll want access to it in Windows or web applications. Here are some examples of how to redirect TextWriter output such as the DataContext log to other destinations.