Mobile Zone is brought to you in partnership with:

Shay is a DZone MVB and is not an employee of DZone and has posted 23 posts at DZone. View Full User Profile

ADF Mobile Logging on Android

05.16.2013
| 1290 views |
  • submit to reddit

I posted before on how to do code level debugging in your ADF Mobile application, but sometimes debugging is an overhead and you would rather just put out some log messages that will allow you to track what's going on where.

ADF Mobile has built in support for a logging framework and it is documented in this chapter in the ADF Mobile Developer Guide.

You can use a line of code like this in your code:

Logger.getLogger(Utility.APP_LOGNAME).logp(Level.INFO, this.getClass().getName(), "Shay","We invoked the button"); 

Then don't forget to set the right level of logging (and possibly the log message format) in the logging.properties file under your META-INF directory. 

The logging chapter in the doc, doesn't mention where to actually see the messages being logged.

One utility that you can use to see your log messages comes with the Android SDK - look into the tools directory there and you'll find the ddms.bat file - run it and you'll be able to see the log messages from your application.

On the side of that utility you can also define filters to just show you the messages you are interested in.

Here is a quick demo showing how this all works together:

By the way - a comment I got pointed out that ddms is old school and you should be using the new monitor.bat at the same locaiton. This will basically work just the same and will look like this:




Published at DZone with permission of Shay Shmeltzer, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)