Loggers & Listeners

[This is preliminary documentation and subject to change.]


NAnt has two related features to allow the build process to be monitored: listeners and loggers.


A listener is alerted of the following events:


Loggers extend the capabilities of listeners and add the following features:

Built-in Listeners/Loggers

Class Description Type
NAnt.Core.DefaultLogger The logger used implicitly unless overridden with the -logger command-line switch. IBuildLogger
NAnt.Core.MailLogger Extends DefaultLogger such that output is still generated the same, and when the build is finished an e-mail can be sent. IBuildLogger
NAnt.Core.XmlLogger Generates output in XML format. IBuildLogger


Simply run NAnt normally, or:

NAnt.exe -logger:NAnt.Core.DefaultLogger


The MailLogger captures all output logged through DefaultLogger (standard NAnt output) and will send success and failure messages to unique e-mail lists, with control for turning off success or failure messages individually.

Properties controlling the operation of MailLogger are:

Property Description Required
MailLogger.mailhost The mail server to use. No, default is "localhost"
MailLogger.from The address of the e-mail sender. Yes, if mail needs to be sent.
MailLogger.failure.notify Send build failure e-mails ? No, default is "true".
MailLogger.success.notify Send build success e-mails ? No, default is "true".
MailLogger.failure.to The address to send build failure messages to. Yes, if failure mail is to be sent.
MailLogger.success.to The address to send build success messages to. Yes, if success mail is to be sent.
MailLogger.failure.subject The subject of build failure messages. No, default is "Build Failure".
MailLogger.success.subject The subject of build success messages. No, default is "Build Success".


NAnt.exe -logger:NAnt.Core.MailLogger


Writes all build information out to an XML file named log.xml, or the value of the XmlLogger.file property if present, when used as a listener. When used as a logger, it writes all output to either the console or to the value of -logfile.

Whether used as a listener or logger, the output is not generated until the build is complete.


NAnt.exe -listener:NAnt.Core.XmlLogger
NAnt.exe -logger:NAnt.Core.XmlLogger -logfile:buildlog.xml