## Echo

### Description

Echoes a message to the current loggers and listeners which means `System.out` unless overridden. A level can be specified, which controls at what logging level the message is filtered at.

The task can also echo to a file, in which case the option to append rather than overwrite the file is available, and the level option is ignored

### Parameters

Attribute | Description | Required
--- | --- | ---
message | the message to echo. | No; defaults to a blank line unless text is included in a character section within this element
file | the file to write the message to. | No; only one of these may be used
output | the Resource to write the message to (see note). Since Apache Ant 1.8
append | Append to an existing file (or open a new file / overwrite an existing file)? | No; ignored unless output indicates a filesystem destination, default is false
level | Control the level at which this message is reported. One of error, warning, info, verbose, debug (decreasing order) | No; default is warning
encoding | encoding to use. since Ant 1.7 | No; defaults to default JVM character encoding
force | Overwrite read-only destination files. since Ant 1.8.2 | No; defaults to false

### Examples

Basic use:

    <echo message="Hello, world"/>

    <echo message="Embed a line break:${line.separator}"/>

    <echo>Embed another:${line.separator}</echo>

    <echo>This is a longer message stretching over
    two lines.
    </echo>

The newline immediately following the `<echo>` tag is part of the output. Newlines in character data within the content of an element are not discarded by XML parsers.
See W3C Recommendation 26 November 2008 / End of Line handling for more details.

    <echo>
    This is a longer message stretching over
    three lines; the first line is a blank
    </echo>

A message which only appears in `-debug` mode.

    <echo message="Deleting drive C:" level="debug"/>

A message which appears even in `-quiet` mode.

    <echo level="error">
    Imminent failure in the antimatter containment facility.
    Please withdraw to safe location at least 50km away.
    </echo>

Generate a shell script by echoing to a file. Note the use of a double $ symbol to stop Ant filtering out the single $ during variable expansion.

    <echo file="runner.csh" append="false">#\!/bin/tcsh
    java-1.3.1 -mx1024m ${project.entrypoint} $$*
    </echo>

Depending on the log level Ant runs at, messages are print out or silently ignored:

Ant command line | `-quiet`, `-q` | no switch | `-verbose`, `-v` | `-debug`, `-d`
--- | --- | --- | --- | ---

    <echo message="This is error message." level="error"/>

ok

ok

ok

ok

    <echo message="This is warning message."/>

ok

ok

ok

ok

    <echo message="This is warning message." level="warning"/>

ok

ok

ok

ok

    <echo message="This is info message." level="info"/>

not logged

ok

ok

ok

    <echo message="This is verbose message." level="verbose"/>

not logged

not logged

ok

ok

    <echo message="This is debug message." level="debug"/>

not logged

not logged

not logged

ok