Record

Description

A recorder is a listener to the current build process that records the output to a file.

Several recorders can exist at the same time. Each recorder is associated with a file. The filename is used as a unique identifier for the recorders. The first call to the record task with an unused filename will create a recorder (using the parameters provided) and add it to the listeners of the build. All subsequent calls to the record task using this filename will modify that recorder's state (recording or not) or other properties (like logging level).

Some technical issues: the file's print stream is flushed for finished events (buildFinished, targetFinished and taskFinished), and is closed on a buildFinished event.

Parameters

Attribute Description Required
name The file path to which this recorder will record to. This can either be a absolute path or a relative path. Yes
action This tells the logger what to do: should it start recording or stop? The first time that the recorder task is called for this logfile, and if this attribute is not provided, then the default for this attribute is start. If this attribute is not provided on subsequent calls, then the state remains as previous. Value can be start or stop. No
append Should the recorder append to a file, or create a new one? This is only applicable the first time this task is called for this file. Value can be yes or no. No; default is no
emacsmode Removes [task] banners like Apache Ant's -emacs command line switch if set to true. No; default is false
loglevel At what logging level should this recorder instance record to? This is not a once only parameter (like append is)—you can increase or decrease the logging level as the build process continues. Value can be error, warn, info, verbose or debug. No; default is info
relativeToBaseDir If name is a relative file path then setting this to yes will treat the file path as relative to the basedir of the project. A value of no, will treat the relative file path as relative to the current working directory of the process. Since Ant 1.10.18 No; defaults to no

Examples

The following build.xml snippet is an example of how to use the recorder to record just the <javac> task:

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

The following two calls to <record> set up two recorders: one to file records-simple.log at logging level info (the default) and one to file ISO.log using logging level of verbose.

    ...
    <record name="records-simple.log"/>
    <record name="ISO.log" loglevel="verbose"/>
    ...