简体   繁体   中英

How to redirect output by a diffrent process initiated by java

I have a java program running on Linux machine. It invokes an ant target to execute. I can see the logs on the screen printed but there is no log file, which was produced when i used to run it using shell script. I want to redirect the screen logs into a file. I tried "tee" to redirect but it redirects only the part that i am printing in java class. Can some one help me with this.

Inside your build.xml file, you can start and stop recording to a log file:

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

See the appropriate ant documentation for more details.

If you'd rather not edit the build.xml, it is probable that ant is using stderr rather than stdout. Find out what shell you are using and look up how to redirect stdout to stderr. For example, in bash, it would be ant 2>&1 | tee file.log ant 2>&1 | tee file.log .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM