Linux – How to run c++ and get the output in a log file

linuxshellUbuntu

I have a c++ code got started by a shell script. The shell script has the following line to start the c++ code /home/user/test_client/a.out Now i want to capture the output of this code in a file called message.log What is the right way to do this ? I have tried /home/user/test_client/a.out >> message.log It doesn't work. Am I doing anything wrong here ?

Best Answer

Try a.out >> message.log 2>&1

That will also redirect stderr, which is probably where the messages are going.