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?
Asked
Active
Viewed 1,493 times
6
-
what console log? this is C++- not JS, isn't it? – starball Aug 27 '23 at 06:38
1 Answers
1
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.

VonC
- 1,262,500
- 529
- 4,410
- 5,250
-
As vscode is launching the application there is no opportunity to tee the output. – Andy Tomlin Jun 12 '18 at 18:30
-
@AndyTomlin Sure, but could you launch the app from a VSCode regular terminal, just for testing? – VonC Jun 12 '18 at 18:31
-
We are running the debugger. We solved the problem by just handling it inside the app and redirecting cout internally to a file. Not very satisfying but a work around for now. – Andy Tomlin Jun 13 '18 at 00:26
-
@AndyTomlin OK. I have included your comment in the answer for more visibility. – VonC Jun 13 '18 at 00:28