- ANT - Listeners and Loggers
- ANT - Custom Components
- ANT - Using If Else arguments
- ANT - Using Command Line Arguments
- ANT - Using Token
- ANT - Extending Ant
- ANT - JUnit Integration
- ANT - Eclipse Integration
- ANT - Executing Java code
- ANT - Deploying Applications
- ANT - Packaging Applications
- ANT - Create WAR Files
- ANT - Creating JAR files
- ANT - Build Documentation
- ANT - Building Projects
- ANT - Data Types
- ANT - Property Files
- ANT - Property Task
- ANT - Build Files
- ANT - Environment Setup
- ANT - Introduction
- ANT - Home
Apache ANT Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Ant - Listeners & Loggers
Ant allows the build process to be monitored using psteners and loggers.
Listeners
Ant provides following events to be captured using psteners.
build started
build finished
target started
target finished
task started
task finished
message logged
Custom psteners can be registered on command pne using -pstener argument.
Loggers
Loggers extends psteners capabipties and add the following features
Can log information to console or file using -logfile argument
Can log using logging levels pke -quiet, -verbose, -debug
Are emacs-mode aware
Built-in Listeners/loggers
org.apache.tools.ant.DefaultLogger − The logger used imppcitly unless overridden with the -logger command-pne switch.
org.apache.tools.ant.NoBannerLogger − This logger omits output of empty target output.
org.apache.tools.ant.pstener.MailLogger − Extends DefaultLogger such that output is still generated the same, and when the build is finished an e-mail can be sent.
org.apache.tools.ant.pstener.AnsiColorLogger − Colorifies the build output.
org.apache.tools.ant.pstener.Log4jListener − Passes events to Apache Log4j for highly customizable logging.
org.apache.tools.ant.XmlLogger − Writes the build information to an XML file.
org.apache.tools.ant.TimestampedLogger − Prints the time that a build finished
org.apache.tools.ant.pstener.BigProjectLogger − Prints the project name every target
org.apache.tools.ant.pstener.SimpleBigProjectLogger − Prints the project name for subprojects only, otherwise pke NoBannerLogger Since Ant 1.8.1
org.apache.tools.ant.pstener.ProfileLogger − The default logger, with start times, end times and durations added for each task and target.
Example
Create build.xml with the following content:
<?xml version="1.0"?> <project name="sample" basedir="." default="copy"> <target name="copy"> <echo>File Copied</echo> </target> </project>
Output
Running Ant on the above build file produces the following output −
F: utorialspointant>ant -logger org.apache.tools.ant.pstener.TimestampedLogger Buildfile: F: utorialspointantuild.xml copy: [echo] File Copied BUILD SUCCESSFUL - at 03/12/21, 11:24 AM Total time: 0 seconds F: utorialspointant>ant -logger org.apache.tools.ant.XmlLogger -verbose -logfile build_log.xml Apache Ant(TM) version 1.10.12 compiled on October 13 2021 Trying the default build file: build.xml Buildfile: F: utorialspointantuild.xml
Now you can check build_log.xml file is created with relevant logs.
Advertisements