Monitoring CruiseControl itself
As much as we like CruiseControl, to some developers it feels like it is a bit of blackbox. People want feedback that their build is in the queue.. Or, if you have a really long running build, what step the build has reached. However, how do you expose this information? There are a couple approches:
Use tail -f cruisecontrol.log and just see what is happening. This is simple and easy, but requires logging onto the box that is running cruisecontrol.
Expose the log files via HTTP and allow people to download. This works while logs are small, but is not a viable long term solution.
Or, best of all, use the existing infrastructure provided with Log4J and Chainsaw!.
Steps to Follow:
1) Add a custom log4j.properties that overrides the one in cruisecontrol.jar by putting this file in /main/dist/log4j.properties:
Make sure the port you picked isn't in use for something else! Also, I have had to put log4j.properties in the cruisecontrol.jar, although this shouldn't be needed.
2) Then, fire up Chainsaw, a GUI for Log4j. It is available via Java WebStart http://logging.apache.org/log4j/docs/chainsaw.html
3) You then want to create a new SocketHubReciever, and provide the port and ip address of the CruiseControl machine. Also give the receiver a name as well like "CruiseControl Events" and pick the threshold, like INFO or DEBUG of events you want.
Monitoring your builds
Now it's nice to monitor CruiseControl with Chainsaw, but what about your builds? In our setup, the default logfile generated by Ant's XMLLogger is over 130MB, which we just don't have the disk space to store too many copies of.
There is a way you can have the best of both worlds (sort of). Try this in your cruisecontrol.xml configuration file:
IMPORTANT: Notice how we're passing arbitary ant parameters in the "target" attribute? This is because this attribute (as of CC 2.3.1) is simply appended to the end of the Ant command line. To get this to work properly, you probably need to either use the "anthome", or "antscript" attributes,
otherwise the command line for Ant is constructed in a different way (see http://cvs.sourceforge.net/viewcvs.py/cruisecontrol/cruisecontrol/main/src/net/sourceforge/cruisecontrol/builders/AntScript.java?rev=1.2&view=auto for exactly how it constructs the command line.
In /etc/cruisecontrol/buildX-settings, create a "log4j.properties" file that looks like this:
And presto!, you can now telnet in and watch your build as it goes. As per the example above, your log4j.properties file for Ant could also use the SocketHubAppender and you could connect to the build with Chainsaw.
Note that because this particular instance of log4j is only for your Ant build, the socket will only be alive while the build is in progress. However, the options with the log4j setup are almost limitless. For example, you could get Ant to push all the logmessages to a Jabber chatroom for example, and anyone interested simply needs to join the room.
Using this setup, you can keep your nice small sized log.xml files (from uselogger=true, and usequiet=true if you do that), but you can still have full access to your build messages, without wasting lots of disk space.