tags:

views:

525

answers:

2

Hi,

I have an external dll written in c#. I studied from the dll's documentations that this tool writes its debug messages to the console using console.writeline.

I 'd like to execute this tool from windows appliaction. when I do that, I loosing those debug messages since windows applications does not have a console...

is there a way to capture those messages? (even to a simple log file) ofcourse using the ProcessInfo.RedirectStandartOutput will not work as i do not use the dll as a process.

many thanks, ofer

+9  A: 

Call Console.SetOut with a TextWriter you control (e.g. a StringWriter).

Jon Skeet
A: 

You would be best served using the System.Diagnostics namespace and Debug.WriteLine instead. Debug supports 'listeners' that can be added at run-time or via the app/web.config files. For example:-

  Debug.Listeners.Add(new ConsoleTraceListener())

If you implement any custom debug logging as a trace listener, you can capture your trace messages application wide very easily.