Monday, February 09, 2009


Minimal code to perform logging in Google Android

To produce log message in Google Android is really quite easy.

At the top of the file in the imports section add: import android.util.Log;

And then in your code you add Log.d(TAG,message);

Where TAG and message are strings.

It is considered good form that the TAG is a constant for the class.

So I put something like this at the top of the class private static final String TAG = Foo.class.getName();

There are several levels of logging and in level order these are Log.v(), Log.d(), Log.i(), Log.w() and Log.e()

v = verbose
d = debug
i = info
w = warning
e = error

The logging is performed by LogCat which can be accessed via the adb tool that comes with the Android developer kit.

tools/adb logcat will start logging at the INFO level as that is the default.

tools/adb logcat *:V will log everything at VERBOSE level.

tools/adb logcat Wibble:W will filter most things and only show those log statements with the tag Wibble at the WARNING level.


you are weird
Being called weird by someone anonymous. Well that is, unusual, not.
Post a Comment

Subscribe to Post Comments [Atom]

<< Home

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]