将stdout和stderr重定向到Microsoft Visual Studio的输出调试控制台 [英] Redirect stdout and stderr to the output debug console of microsoft visual studio

查看:275
本文介绍了将stdout和stderr重定向到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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆