EchoFilter

Description

Echofilter is used to echo (print) its input. It is useful for debugging purposes but also to output something in a file.
Used as the last filter in a filterchain, with the 'file' attribute, it behaves as the Unix command 'tee'.
With its 'contains' and 'match' attributes, you can choose to print only certain lines, without filtering the others.

Definition

Using typedef:
<typedef name="echofilter"
         classname="net.sf.antcount.filters.EchoFilter"
         classpath="antcount.jar" />
Using inline definition with filterreader:
<filterreader classname="net.sf.antcount.filters.EchoFilter"
         classpath="antcount.jar" />

Attributes

Name Description Required Default
contains If this is set, the input will be echoed only if it contains the specified string. No All input is echoed
match If this is set, the input will be echoed only if it matches this regular expression. No All input is echoed
file The file to print to. No Output on the console
append When writing to a existing file, should we append to it? No False
encoding The encoding to use when printing in a file No Default system encoding

Examples

Print all lines containing 'xxx' in x.log and all lines containing 'yyy' in y.log

<concat destfile="y.log">
  <fileset dir="${log.dir}" includes="**/*.log" />
  <filterchain>
    <echofilter contains="xxx" file="x.log" />
    <linecontains>
      <contains value="yyy" />
    </linecontains>
  </filterchain>
</concat>