how to configure in my app.config a TextWriterTraceListener to use System.Console.Out ?

D

Didier Bolf

hello

I'd like to add a listener in the app.config of my application, something like
<add name="myListener" type="System.Diagnostics.TextWriterTraceListener"/>
I can use initializeData="mylog.txt" to trace in a file but I 'd like to trace in
the console but I can't find how to do ... I can't see any samples of that in msdn
or elsewhere

thanks for your help
didier
 
J

Jon Skeet [C# MVP]

Didier Bolf said:
I'd like to add a listener in the app.config of my application, something like
<add name="myListener" type="System.Diagnostics.TextWriterTraceListener"/>
I can use initializeData="mylog.txt" to trace in a file but I 'd like to trace in
the console but I can't find how to do ... I can't see any samples of that in msdn
or elsewhere

I don't know about the trace listener side of things, but it sounds
like you want to redirect the console, so use Console.SetOut to set the
output to your own custom TextWriter which then writes the output
however you want it to.
 

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

Top