Apache Ant – Capture Ant output log using recorder task

There is a <record> task in Ant so you could save the Ant output during the Ant Build. Here is an example.

1. build.xml

<project name="ant-recorder-example" default="record" basedir=".">
  <target name="record">
    <record name="${basedir}/build.log" action="start" append="yes"/>
      <!--
        Whatever ant tasks being executed here,
        the output would be recorded by the recorder
      -->
      <echo message="Hello world"/>
      <echo message="All the above output will be recorded down in the build.log."/>
      <echo message="After the run, check the build.log."/>
    <record name="${basedir}/build.log" action="stop" append="yes"/>
  </target>
</project>

 

2. Run Ant
ant-recorder-example
 

3. Check the build.log
ant-recorder-example-2
 

Done =)

Reference: Ant – Recorder Task

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s