Welcome Android Developpers

Welcome Android Developpers
My name is Mathias Séguy, I am an Android Expert and Trainer and created the Android2EE company.

For full information, it’s here : Android2EE's Training
You can meet me on Google+, follow me on Twitter or on LinkedIn

Monday, November 14, 2011

Where are my Android logs ? in your DDMS ;o)


Bandeau Conference
Hello,

Noting that I took a very long time to find my logs Android, I told myself that I was not the only one. And indeed, in dev room, I was not alone.

So where are the logs and how to implement them?


It is quite easy:
In Eclipse open the DDMS perspective then the Logcat view. In fact Logcat view is the view in which the logs will be displayed in your application.
Sometimes nothing is displayed in this view, you have to simply click, in the device view, on the emulator (or device) you want to "listen" and magicaly, your logs appear in the order Logcat. The logs bound to that emulator.


Perspective DDMS

The tip is to add this view (Logcat) in your Java perspective not to have to move in the DDMS perspective each time you want to see your log.

Logcat view is a table that displays a log line. This table consists of five columns ordered like that:
  • Time: displays the time of issuance of the log
  • Level: the level of your log (Verbose, Debug, Info, Warn, Error)
  • Pid: the number of processes that issued the log
  • Tag: The tag log
  • message: the message log

Now how to make a log in your application. It is also quite simple:
Just use the Log class (android.util.Log) and their static methods v, d, i, w, e to make a log with the level Verbose, Debug, Info, Warn and Error. These methods have the same signature void *** (String tag, String message).
The tag and the message can be found in column 4 and 5 of Table Logcat.
By default, the tag I put is a static variable in my class:
private static final String tag = "MyClassName". For example:
Log.v("MyClassName", "MyMessage: Hello guy");

One last thing about logs is the ability of the Logcat view to set up filters, based either on the level either on the tag.


So, Thanks who?
Thanks, Android2ee, the Android Programming Ebooks :o)

Mathias Séguy
mathias.seguy.it@gmail.com
Auteur Android2EE
Ebooks to learn Android Programming.
AndroidEvolution

No comments:

Post a Comment