turn off tracewriter from writing to output file

ldjpr

Member
Joined
Jan 11, 2009
Messages
7
Programming Experience
3-5
Hello

I have inherited a a vb.net that uses DefaultTraceListener and writes debug messages to an output file. The app. is full commands such as: traceWriter.WriteLine. Is there a way that I could disable the printing to the output file without having to comment all lines?

Thanks

ldj
 
Set the Filter to a (new) EventTypeFilter with EventType=Off, this require that you use categories, like tr.WriteLine("hi", "cat1"), and not tr.WriteLine("hi").
 
Thanks for the reply.

Is there a way so the output is not not written to the file without having to modify all lines?

ldj
 
No, not if you just use listener.WriteLine(string). For more flexibility you can add your listener to the Trace.Listeners and write through the Trace class instead of directly to your private listener. You can then also dynamically add/remove your listener from the Trace.Listeners. Another benefit is you can include/exclude all trace calls from a build configuration with just a checkbox in advanced compile options, this option is more beneficial for Debug writes actually, and it shows for default settings Debug is excluded for release builds while Trace is included. In addition it should be mentioned that Trace class has better methods for writing various types of messages.
 
Back
Top