Javatpoint Logo
Javatpoint Logo

Apache Ant Listeners and Loggers

It is a feature which allows us to monitor the progress of Ant's progress during execution. Ant uses two concepts for monitoring: listeners and loggers and both are provided by Ant itself. See the all supported listeners below.

Listeners

  1. build started
  2. build finished
  3. target started
  4. target finished
  5. task started
  6. task finished
  7. message logged

Loggers

loggers are used to extend the listeners capabilities. It has the various features, see below.

  1. It log information to the console or the file specified using -logfile parameter.
  2. It is logging level (-quite, -verbose, -debug) aware.
  3. Emacs-mode aware

Apache Ant Listeners and Loggers interface can also be represented in UML. See an UML diagram below.


Apache Ant Listeners and Loggers

It is a UML diagram of BuildListener and BuildLogger interface.

Built-in Listeners and Loggers

DataType Parameter Description
org.apache.tools.ant.DefaultLogger It is default logger and be overridden with the -logger command-line switch. BuildLogger
org.apache.tools.ant.NoBannerLogger It is used to omit output of empty target output. BuildLogger
org.apache.tools.ant.listener.MailLogger It extends DefaultLogger and generate the same output and send an email too. BuildLogger
org.apache.tools.ant.listener.AnsiColorLogger It is used to provide colors to the build output. BuildLogger
org.apache.tools.ant.listener.Log4jListener It is used to pass events to Apache Log4j logging. BuildListener
org.apache.tools.ant.XmlLogger It writes the build information to an XML file. BuildLogger
org.apache.tools.ant.TimestampedLogger It is used to print the time that a build finished. BuildLogger
org.apache.tools.ant.listener.BigProjectLogger It is used to print the project name every target has. BuildLogger
org.apache.tools.ant.listener.SimpleBigProjectLogger It prints the project name for subprojects only. BuildLogger
org.apache.tools.ant.listener.ProfileLogger It is a default logger with start times, end times and durations added for each task and target. BuildLogger

Any number of build listeners can be attached to a project. We can use listener while running ant from the command line by specifying listener class.

Default Logger

DefaultLogger can be run using the below command, see we have passed DefaultLogger class here.

Mail Logger

MailLogger uses DefaultLogger to capture all output logs and send success and failure message through unique email lists.

MailLogger Class Properties

Property Description Required
MailLogger.mailhost Mail server to use No; default localhost
MailLogger.port SMTP Port for the Mail server No; default 25
MailLogger.user user name for SMTP auth Yes, if SMTP auth is required on your SMTP server
MailLogger.password password for SMTP auth Yes, if SMTP auth is required on your SMTP server
MailLogger.ssl on or true if SSL is needed This feature requires JavaMail No
MailLogger.from Mail from address Yes, if mail needs to be sent
MailLogger.replyto Mail replyto address(es), comma-separated No
MailLogger.success.to Address(es) to send success messages to, comma-separated Yes, if success mail is to be sent
MailLogger.success.cc Address(es) to send success messages to carbon copy (cc), comma-separated No
MailLogger.success.bcc Address(es) to send success messages to blind carbon copy (bcc), comma-separated No

MailLogger at Command Line

ex.





Help Others, Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA