Windows:确定哪个输出流 # (1-9) 控制台输出来自?

Cor*_*te5 5 windows command-line io cmd.exe

我过去曾看到过有关“突出显示”STDOUT 和 STDERR 之间不同输出流的问题,但我想知道在 Windows 上是否有更简单的方法来做到这一点。

我感兴趣的原因是因为我在流 3 和 4 上有多个应用程序打印输出,这导致结果混乱和不必要的调试,直到我随机检查每个可能的输出流。

有没有人有一个很好的内置解决方案来确定哪个输出流控制台输出来自?我想应该有某种监视器(SysInternals?WMI?)来显示控制台上打印的信息来自哪里?

Vom*_*yle 3

有谁有一个好的内置解决方案来确定哪个输出流控制台输出来自?

您可以相应地使用重定向语法来查看STDOUT 与 STDERR 来分隔文件。在下面的示例中,fileA 将包含 STDOUT,而 fileB 将包含 STDERR。

例子: 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
Run Code Online (Sandbox Code Playgroud)

来源


更多资源