将stdout和stderr重定向到Microsoft Visual Studio的输出调试控制台 [英] Redirect stdout and stderr to the output debug console of microsoft visual studio
问题描述
我正在使用Microsoft Visual Studio进行C ++. 我在IDE的输出控制台中看不到std :: err和std :: out. 有没有办法重定向它们?
I am using microsoft visual studio to do C++. I don't see std::err and std::out in the output console of the IDE. Is there a way to redirect them ?
推荐答案
您确实可以重定向std :: out和std :: err.只需在解决方案资源管理器中右键单击您的项目,然后选择Properties
.然后选择Configuration Properties -> Debugging
并将适当的参数放入Command Arguments
字段.例如,要将std :: err重定向到文件,我将输入2> ErrorLog.txt
.
You can indeed redirect std::out and std::err. Simply right click on your project in the solution explorer and select Properties
. Then select Configuration Properties -> Debugging
and put the appropriate arguments into the Command Arguments
field. For example, to redirect std::err to a file, I would type in 2> ErrorLog.txt
.
在Command Arguments
中键入的内容仅在Visual Studio运行程序时作为命令行参数附加,就像您在控制台中手动键入它们一样.因此,上面的示例只是告诉VisualStudio使用命令<programName>.exe 2> ErrorLog.txt
而不是<programName>.exe
运行您的程序.
The things you type in Command Arguments
simply get appended as command line arguments when Visual Studio runs your program, just like you had manually typed them in to the console. So, the above example simply tells VisualStudio to run your program with the command <programName>.exe 2> ErrorLog.txt
instead of just <programName>.exe
.
这篇关于将stdout和stderr重定向到Microsoft Visual Studio的输出调试控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!