Logging to a remote location

Robert Galvin -
3 MIN READ

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

2)

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;

 

   

   

   

   

   

   

   

   

   

   

 

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:

rho-logger.PNG

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.

rho-logger-win7.PNG

rho-logger-options-win7.PNG

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.

rho-logger-listening.PNG

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.

profile

Robert Galvin

Please register or login to post a reply

5 Replies

J Joshua McGinnis

Unfortunately, I was unable to get it to work. I followed your instructions. My PC has an ip of 192.168.1.5 so I set the config file to   I used HttpNameSpace Manager to verify *:80/Temporary_Listen_Addresses/ is open to everyone. When I start logging, nothing happens.

J James Morley-Smith

Great post, Rob. I have to add that this is a really useful method of debugging your apps, it's definitely worth setting up and having running in the background so you can refer to the data as you code and test your apps.

C Chris Misztur

I left the LogUri value at 192.168.1.1/.  Running the HttpListener as Administrator fixes the Access Denied problem.  You might have something else listening on port 80 already?

R Ronald Diemicke

Yeah - I'm having this same problem where I've set it up per the example but nothing logs.

M Michael Teti

Great post! I have been successful in capturing logs via the provided HTTP Logger application while the device is docked but not while undocked using wifi on a MC9190-G.  Is being docked a requirement for this activity?

Also, can you share the actual Logging API (request params) as I would like to post all logging  to a  specific system.

Thanks!