2010-04-07 52 views

回答

21

您应该使用ant任务<record>。见http://ant.apache.org/manual/Tasks/recorder.html

在你的Ant文件做这样的事情:

... 
<record name="logfile.txt" action="start" append="false" /> 
... 
your ant code... 
... 
<record name="logfile.txt" action="stop"/> 

从蚂蚁两个记录语句之间的输出将被写入 'LOGFILE.TXT'

8

如果你在Unix上,你可以使用tee命令。如果你在Windows上,你可以使用PowerShell来完成同样的事情,你只需要在命令提示符下运行PowerShell,然后执行你的ant命令。

ant | tee "output.log" 
+0

[wintee(https://开头的代码。 google.com/p/wintee/)适用于Windows。 – Malachi 2013-12-11 11:02:04

+1

注意:当ant失败时,此行将始终返回错误代码0,而不是正确的错误代码。 – HyBRiD 2015-12-14 12:14:00