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.
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)
Ebooks to learn Android Programming.