When are developing a RhoElements application one thing that may come in handy is to enabling logging to your PC while you are testing the application on the actual device. To do that, you need to do two things:
1) Enable Logging in the Config.XML
Let's first start by changing some settings in the config.xml file (located on the device \Install Path\config - default install path on Windows Mobile is \Program Files\RhoElements\Config;
<Logger> <LogProtocol value="HTTP"/> <LogPort value="80"/> <LogURI value="192.168.0.165/Temporary_Listen_Addresses/"/> <LogError value="1"/> <LogWarning value="1"/> <LogInfo value="1"/> <LogUser value="1"/> <LogMemory value="1"/> <LogMemPeriod value="5000"/> <LogMaxSize value="10"/> </Logger>
Notice a few things:
- LogProtocol - instead of FILE, I changed it to HTTP
- LogPort - I kept this at 80 (this needs to match the listener app explained below)
- LogURI -change it to the url of where I will be running the http logger application (in my case it is running on my PC on my local network with a virtual sub path - also explained below)
Also note that I have all logging options set to "1" which means that particular log type will be enabled. Notice the LogUser entry. This one allows you to use the generic.Log('Message',1) method in your code to add custom messages to the log file. This is very helpful in debugging application issues. Save all of these settings and copy it back to the device. Be aware that the config.xml file is only read once during startup, so if you have RhoElements running you will need to quit the application and restart in order for the changes to take effect.
Now lets load up the application that will display the log information. Note: This application is made freely available to use but is not supported by Motorola. Unzip the contents and you will see a Visual Studio project that will allow you to make changes, but if you look in the Bin\Release folder you will see an executable. Launch it and you will see:
Nothing is happening at this point. We need to check some settings first and then start the listener. In this demo application, we are using the HttpListner .net Class to listen for HTTP traffic coming in. Usually this type of thing can be blocked on your laptop. If you are having problems on your particular OS, just do some Google searches on this topic and you may find some solutions. In my case that is exactly what happened to me. For me I was running a Windows 7 laptop which had a lot of the corporate security policies in place. One of them did not allow the app above to run under the default settings. I kept getting "Access Denied" when I tried to start logging. So I had to download this HttpNameSpace Manager app I found on the MSDNt that allowed me to see what namespaces/ports where available for the HttpListener to listen on. Looking the the settings, I found that port 80/Temporary_Listen_Addresses/ looked like it was granted to "Everyone" on my laptop. So I went with this one. Whatever works, just make sure you have the port and the virtual path the same in the config.xml and the http logger application.
So now I am ready to go. Save the settings and then Click Log/Start to begin listening. Now launch your application and you should see information display in the http logger application.
Note: When logging to HTTP, the local logging will not be created. It is an either or condition. But sometimes this comes in very handy for when you are working through debugging your application once the app is executes on a real device.