Configuring CruiseControl.NET to publish exceptions outside of build tasks

The other day I blogged about plug-ins I’ve been writing for CruiseControl.NET for a custom process that I’m working on. I’ve written a custom <sourcecontrol> plug-in that monitors a directory on an FTP server for new files. If files are present they’re downloaded and a build is triggered. The <sourcecontrol> tag of my ccnet.config file section looks like this:

<sourcecontrol type="ftp"> <remoteHost>localhost</remoteHost> <userName>User</userName> <password>pwd</password> <localPath>c:\temp\</localPath> <remoteDir>out</remoteDir> <timeOut>2</timeOut> <fileMask>*.*</fileMask> </sourcecontrol>

A problem I was running into was that exceptions, like failed FTP connections, within my sourcecontrol plug-in weren’t being published using my email publisher as configured in ccnet.config. Prior to v1.1 this used to work using if you had following tag in your ccnet.config file:


With v1.1 came support for log4net replacing the functionality of this tag which is mentioned here but without further details as to the alternative. To publish these exceptions you have to configure a log4net SmtpAppender to sent email which can be done from app.config as follows:

<appender name="SmtpAppender" type="log4net.Appender.SmtpAppender"> <to value="" /> <from value="" /> <subject value="test logging message" /> <smtpHost value="smtpserver" /> <bufferSize value="512" /> <lossy value="true" /> <evaluator type="log4net.Core.LevelEvaluator"> <threshold value="WARN"/> </evaluator> <layout type="log4net.Layout.PatternLayout"> <conversionPattern
value="%newline%date [%thread] %-5level %logger [%property{NDC}] -
/> </layout> </appender>

Btw, don’t forget to configure this appender in the <root> node of the <log4net> section as well. It’s a bit of a bummer that you have to have two Smtp setups to handle these kinds of exceptions but at least you have the capability to get the information published.

[Update: Dec 19, 2007] To clarify the exception I’m referring to above is occurs in my implementation of ISourceControl.GetModifications.