How to get logging on MSMQ on a Windows Mobile Device

If you're having problems with MSMQ on a general embedded device, you can build a debug image and setup very verbose logging in order to see what's going wrong.  On a Windows Mobile device debugging MSMQ is harder and you can't get as much information (since we only ship retail MSMQ DLLs), but there is a basic retail logging built in that will record some fatal errors and can (sometimes) be used to determine where something is going wrong.

I'm writing this in the context of helping a customer on the newsgroups debug through an MSMQ issue where it won't work properly at startup, though these log messages may also help with other run-time issues.  For now I'm assuming it's an initial setup problem in my steps below.

1 - Uninstall MSMQ from the WM device, if not already.  You want to make sure you really clean it out well, so do the following:

Uninstall MSMQ CAB
Delete registry HKLM\Software\Microsoft\MSMQ
Delete registry HKLM\Services\MSMQD
Delete [\temp\MSMQ]
On WM I think [\temp\msmq] is \Application Data\Volatile\MSMQ, though in theory the temp directory can be configured to be different.

2 - Reinstall MSMQ CAB file, potentially rebooting if prompted to do so.

3 - Setup MSMQ Logging
Add the following registry value *before* doing anything else with MSMQ
HKLM\software\microsoft\msmq\SimpleClient\LogSize=20 (this means log file will roll over when it reaches 20KB)

4 - Now "register" MSMQ, the way you would for any setup (via visadm->register, or msmqadm->register, or however).

5 - Now start MSMQ.  From here on you should see a very high level log about MSMQ service stopping & starting, as well as certain fatal errors.

The log will be named mqlogfile.txt, and will be in the directory specified either in HKLM\software\microsoft\msmq\SimpleClient\BaseDir or in your device's TEMP\msmq directory.

As I indicated above, your mileage with this may vary since not every possible fatal error is recorded in retail logging.

[Author: John Spaith]