You are here

Add new comment

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 org.apache.tools.ant.XmlLogger -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>
 </task>
 <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>
    <task location="build.xml:1400: " name="ParseDotClasspath" time="0 seconds">
     <message priority="info"><![CDATA[Classpath: ..]]></message>
    </task>
    <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.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
Refresh Type the characters you see in this picture. Type the characters you see in the picture; if you can't read them, submit the form and a new image will be generated. Not case sensitive.  Switch to audio verification.