Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode C++ debug capture console output

I am running VSCode in Ubuntu to debug a C++ program. Debugging a console app with GDB is working fine except I really want to capture the console log output to a file. I cannot see a way or option to do this. Is there any option to capture this console log output?

like image 471
Andy Tomlin Avatar asked Jun 12 '18 00:06

Andy Tomlin


People also ask

How do I get console output in VS Code?

You can press F5 for Debugging or Ctrl-F5 for Run without debugging. When you get a menu asking for environment, select Node. js. You should see output in the Debug Console.

How can I see all the outputs in VS Code?

Go to File>Preferences>Setting and search for the Scrollback setting and increase the value to get the number of lines of output you want. This worked for me. Save this answer. Show activity on this post.


1 Answers

Since there does not seem to be a native feature to save the output of a VSCode terminal, maybe you can use in said terminal a command allowing you to save that session.

See for instance "Gdb print to file instead of stdout"

gdb core.3599 -ex bt -ex quit |& tee backtrace.log

As mentioned, the output is written to backtrace.log and also on the screen.

As the OP Andy Tomlin mentions in the comments, this is not compatible with a debugger session.

We solved the problem by just handling it inside the app and redirecting cout internally to a file.

like image 176
VonC Avatar answered Sep 28 '22 12:09

VonC