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

后端 未结 3 432
鱼传尺愫
鱼传尺愫 2021-01-07 20:41

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 ?

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-07 21:28

    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 .exe 2> ErrorLog.txt instead of just .exe.

提交回复
热议问题