Christopher Dancy
Christopher Dancy

Reputation: 656

Getting ant to log to file as well as screen/terminal

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?

Upvotes: 19

Views: 28796

Answers (2)

pablaasmo
pablaasmo

Reputation: 576

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'

Upvotes: 28

Rob Tanzola
Rob Tanzola

Reputation: 1795

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"

Upvotes: 8

Related Questions