Offler
Offler

Reputation: 1223

How to configure Debug.WriteLine output file?

System.Diagnostics.Debug.WriteLine is used for tracing.

Funilly a file C:\Users\Public\Documents\UserNameFromProgramContext\ProgramName.asserts is created on my machine, but not on that of another developer.

I only wanted Debug.WriteLine for output in the Output Window of VS.

Where is it possible to configure the place where Debug.WriteLine writes to?

Upvotes: 1

Views: 1587

Answers (1)

Serve Laurijssen
Serve Laurijssen

Reputation: 9733

simple:

Debug.Listeners.Add(new TextWriterTraceListener("c:\\temp\\test.txt"));
Debug.AutoFlush = true;
Debug.WriteLine("test");

so just use the Listeners collection to manipulate where debug data is written to

Upvotes: 3

Related Questions