Redirect stdout and stderr to the output debug console of microsoft visual studio

0x26res picture 0x26res · Apr 21, 2010 · Viewed 21.8k times · Source

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 ?

Answer

Brandon picture Brandon · Aug 5, 2011

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.

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.