Windows: Determining which output stream # (1-9) console output is coming from?

4

I've seen questions in the past about "highlighting" different output streams between STDOUT and STDERR, but I was wondering if there was maybe a simpler way to do this on Windows.

The reason I became interested was because I've had more than one application print output on streams 3 & 4, which led to confusing results & unnecessary debugging until I randomly checked every possible output stream.

Does anyone have a good built-in solution for determining which output stream console output is coming from? I imagine there should be some sort of monitor (SysInternals? WMI?) that would show where information being printed on the console is coming from?

Coruscate5

Posted 2016-08-30T18:52:40.727

Reputation: 844

Answers

1

Does anyone have a good built-in solution for determining which output stream console output is coming from?

You can just use Redirection syntax accordingly to see STDOUT versus STDERR to separate files. In the below example, fileA would contain STDOUT where fileB would contian STDERR.

Example: command >> fileA 2>> fileB Redirect output and errors to separate files

STDIN  = 0 Keyboard input 
STDOUT = 1 Text output 
STDERR = 2 Error text output 
UNDEFINED = 3-9

 command 2> filename       Redirect any error message into a file   
 command 2>> filename      Append any error message into a file  
(command)2> filename       Redirect any CMD.exe error into a file   
 command > file 2>&1       Redirect errors and output to one file       
 command > fileA 2> fileB  Redirect output and errors to separate files

source


Further Resources

Pimp Juice IT

Posted 2016-08-30T18:52:40.727

Reputation: 29 425

This does in fact work, but requires me to do work on the front-end (& make some assumptions that the output stream is not coming from where it normally would - i.e. STDOUT). I was thinking more like something that could show me, like Wireshark does for network responses, "received response from PROGRAM on stream 3". – Coruscate5 – 2016-08-31T17:21:14.980

@Coruscate5 I think this would depend on what each output stream process, executable, etc. supports and what it allows to be logged at that level to help determine the different processes or whatever that each stream is generated from if that means from different executable processes for example. If these instances are always from the same one executable or streaming process, then I assume a time and date stamp would suffice to the millisecond perhaps if that's how fast this is running. With WireShark and SYN, ACK, etc. packets, that's showing the TCP/IP protocol packets at work. – Pimp Juice IT – 2017-07-24T03:03:59.557

@Coruscate5 So what type of processes are you working with that are generating these streams and what exactly do you need to get from each output to identify what exactly? I'm wondering what the source is like in-house compiled VB console apps or what. Wondering if either executable name or its name and a time stamp would suffice in the STDOUT and STERR to help differentiate whatever you are looking to do that with. Help clarify some so I can look into this more and put more thoughts into it for sure. – Pimp Juice IT – 2017-07-24T03:06:10.653