You are here

More readable log for complex Ant outputs with XmlLogger

When your build.xml is complex, it is not easy to read default Ant log output and understand which tasks are currently on the stack. You can use XmlLogger to the rescue (also works in Eclipse 3.4):

ant -logger -logfile build_log.xml
(Details can be found at Ant listener)

The output looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="log.xsl"?>

<build time="12 seconds">
 <task location="build.xml:198: " name="echo" time="0 seconds">
  <message priority="warn"><![CDATA[Some message]]></message>
 <target name="compile" time="11 seconds">
  <task location="build.xml:1548: " name="antcallback" time="0 seconds">
   <target name="privateCompileSingleProject" time="0 seconds">
    <task location="build.xml:1383: " name="if" time="0 seconds" />
    <task location="build.xml:1394: " name="echo" time="0 seconds">
     <message priority="warn"><![CDATA[Providing dependencies ...]]></message>
    <task location="build.xml:1400: " name="ParseDotClasspath" time="0 seconds">
     <message priority="info"><![CDATA[Classpath: ..]]></message>
    <task location="build.xml:1402: " name="property" time="0 seconds" />

As you can see, the output is structured and as a bonus each task has duration and source line reference. With the help of decent XML editor and folding, you can better understand which message belongs to which target and what is the path to the target. Almost something similar as IntelliJ Idea Ant Tree mode, with with more fiddling. Because of the task duration, the output from XmlLogger is generated at the end of build script.

You can also use a XSL transformation to transform XML log to HTML, but it will loose the structure information, see apache-ant\src\etc\log.xsl.


Note that the output will not be generated until the build has finished. If you have a long-running build, you won't see any output to gauge it's progress.