Appending output of a Batch file To log file
batch-file
Solution
Instead of using ">" to redirect like this:
java Foo > log
use ">>" to append normal "stdout" output to a new or existing file:
java Foo >> log
However, if you also want to capture "stderr" errors (such as why the Java program couldn't be started), you should also use the "2>&1" tag which redirects "stderr" (the "2") to "stdout" (the "1"). For example:
java Foo >> log 2>&1
Problem
I have a batch file which calls a java program. The output is redirected to a log file in the same directory. However the log file is replaced everytime the batch file is run... I would like to keep the old outputs in the log file and always append the new output to the log file.