There are several ways of solving this issue, including attaching an external device that would allow me to log the serial port output, or rewriting the drivers to use a logging library. None of these solutions were very appealing, so I started thinking about alternatives...
I realized that I could use CeLog in a way it was probably never intended to, by simply ignoring most of the functionality and only ask it to capture RETAILMSG (and DEBUGMSG) output. For those who have never encountered CeLog, it is a general purpose event-tracking tool that can can log a number of kernel and coredll events. CeLog is normally not enabled in a run-time image, but is simple to add.
So, CeLog more or less solved my problem. It logs events to a memory buffer and a small included application (CeLogFlush.exe) can be configured to regularly dump this buffer to a file on disk. The format of the file generated by CeLogFlush.exe is rather cryptic (binary) and designed for offline processing on your development PC using a tool called Readlog.
While ReadLog is very flexible and can do all sorts of filtering of the data, I wanted a more simple way to see the log messages, and I wanted to be able to see it directly on the device - from a telnet session or via the webserver. So I created a small utility (dumplog.exe) that will dump the log messages from the file (and ignore any other event data, should more events be enabled). I also created a small webserver plugin that will do the same thing, but make the output available as a webpage. The output from both look similar to this:
Windows CE DumpLog 0.1 (Compile time: May 27 2011 11:00:01) Copyright (C) 2009 by Bogong (www.bogong.dk) Dumping celog file: celog.clg 00:00:02.461.338: PID=00400002 TID=00D60002: I2C ioexp: ETH reset toggle bus 8, uAddr 0x74, reg 2, ByteCnt 2, uValue0 0x00, uValue1 0x01 00:00:02.563.764: PID=00400002 TID=00D60002: UfnPdd_ContextSetup: Allocated DMA TX Region PA 0x83400000 VA 0xD0B10000 Size 0x400 00:00:02.571.313: PID=00400002 TID=00D60002: UfnPdd_ContextSetup: Allocated DMA RX Region PA 0x83400400 VA 0xD0B20400 Size 0x400
I have wrapped everything in a package that you can dump into your C:\WINCE600\3rdparty folder and then include in your image by checking one or both of the catalog items.
The tool is hosted on Codeplex, but you need to download from the Source Code tab since I have not yet created a zip-file. A few more details about the tool can be found under Documentation.