I'm trying to get to grips with the System.Diagnostics.Trace class, and I just can't get any output to go to file. Whenever I use a TextWriterTraceListener, all I ever get is an empty file. For example, the following simple app:
Expand|Select|Wrap|Line Numbers
- using System;
- using System.Diagnostics;
- namespace Test
- {
- class Test
- {
- static void Main(string[] args)
- {
- Trace.Listeners.Add(new ConsoleTraceListener());
- Trace.Listeners.Add(new TextWriterTraceListener("trace.txt"));
- Trace.WriteLine("blah");
- }
- }
- }
I've tried both from VS 2005 and just building on the command line, and I've tried with both .NET 2.0 and going back to 1.1. I've tried giving Everyone full permissions on the directory in question. Anyone have any ideas?
Cheers,
- Chris