0

I have a command line utility that outputs a lot of information to the console. Sometimes it output error, which I'd like easily see in real time.

If these errors were output in red it would be very easy to spot them. The problem is that all text lines are the default white.

Is there any way to intercept the console output and reformat it before it's print?

I know I can redirect the output stream of Console.Write but this does not give me the ability to reformat it.

Is there any way of doing this? Can someone just point me to the right direction?

rbasniak
  • 4,484
  • 11
  • 51
  • 100
  • How are you writing error messages? Console.WriteLine? Debug.WriteLine? some logger? – Sergey Berezovskiy Jan 25 '17 at 10:53
  • 1
    It looks like all you need was described here: http://stackoverflow.com/questions/186822/capturing-console-output-from-a-net-application-c and here: http://stackoverflow.com/questions/2743260/is-it-possible-to-write-to-the-console-in-colour-in-net – Andrey Korneyev Jan 25 '17 at 10:54
  • @SergeyBerezovskiy It's a third party application, I have no control on how the messages are output – rbasniak Jan 25 '17 at 13:24
  • I just discovered the `OutputDataReceived` event of the `Process`, which allows me to receive the data as it arrives, then I can format it before it goes to the console. This solves my problem... – rbasniak Jan 25 '17 at 13:25

0 Answers0