Getting ant to log to file as well as screen/terminal
25,853
Solution 1
You should use the ant task <record>
. See http://ant.apache.org/manual/Tasks/recorder.html.
In your ant file do something like:
...
<record name="logfile.txt" action="start" append="false" />
...
your ant code...
...
<record name="logfile.txt" action="stop"/>
The output from ant between the two record statements will be written to 'logfile.txt'
Solution 2
If you are on Unix, you can use the tee command. If you are on Windows, you can use PowerShell to accomplish the same thing, you would just need to run PowerShell at the command prompt and then execute your ant command.
ant | tee "output.log"
Related videos on Youtube
Comments
-
Christopher Dancy almost 4 years
I've searched these forums as well as the internet and could not find a clear answer. I'm executing an ant task. I would like the output to get put to the screen as well as a log file ... how can I do this?
-
HyBRiD over 8 yearsNote: when ant fails, this line will always return error code 0, instead of the proper error code.
-
mikee over 5 yearsBe aware if you use this method you won't see the return code from ant if your running from a script. If your using a shell you can access the return code using $ echo "${PIPESTATUS[0]} ${PIPESTATUS[1]}" (use [1] and [2] for zsh. If your calling ant from rexx I have not found a satisfactory way to get the return code back even with a helper shell script.