The output of a program could be send to stderr or stdout. In the case you want to manage both separatelly:
foo > stdout.txt 2> stderr.txt
or if you want in same file for both message streams:
foo > allout.txt 2>&1
You can also maintain the regular output using 'tee' to split the data flow:
foo 2>&1 | tee allout.txt
Note: this works in (ba)sh, check your shell for proper syntax