How to redirect stdout stderr in an ant script?

你说的曾经没有我的故事 提交于 2019-12-04 02:56:30
ChssPly76

The recorder task may be able to do what you want:

<record name="log.txt" action="start"/>
...
<record name="log.txt" action="stop"/>

Beyond that, certain tasks (exec, java, etc) offer this functionality by themselves (usually by means of output and error arguments)

It's easy:

ant -logfile <logfile> <command>

And you can also say to ant shut up:

ant -q <command>

It worked fine to me.

Try this:

<java classname="some.package.Class"
    fork="yes"
    output="stdouterr.txt">
    ...
</java>

stdouterr.txt will contain both stdout and stderr

<java classname="some.package.Class"
    fork="yes"
    output="stdout.txt"
    error="stderr.txt">
    ...
</java>

stdout.txt and stderr.txt will contain stdout and stderr respectively

From my experience, the record task tends to fail when the ant script is run on cruise control, due to file access permissions (if someone can tell me how to fix that I'll be a happy man).

HTH

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!