Trace listener question

  • Thread starter Thread starter Jason
  • Start date Start date
J

Jason

Hi,

I'm a little confused on using a trace listener. I'm doing this (winforms
app btw not web app)

TextWriterTraceListener listener = new
TextWriterTraceListener("TraceOutput.txt", "filetrace");
Trace.Listeners.Add(listener);
Trace.WriteLine("Starting My Program ")

But in my other forms when I do a Trace.Writeline they don't get written to
the output.txt file. Am I supposed to create new tracelisteners for all the
forms in my project (that I wish to have trace messages)? and what about two
listeners trying to access the output.txt file at the same time?
It's not clear in the docs or anything I can find what to do in this
situation.

Thanks!!
 
What you're doing (with one TraceListener) sounds correct. Are you sure
you're writing to the Trace object after you've attached the
TextWriterTracListener? Also, have you called Trace.Flush() to see if that
resolves the problem?

Ken
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top