Here and Here are a couple of places that got me started. First the standard java logging mechanism doesn’t work. In addition System.out.print doesn’t work. You need to use the android.util.log.
package com.saville.tests;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
@StateMachine
public class test extends Activity
{
/** Called with the activity is first created. */
@Override
public void onCreate(Bundle icicle)
{
super.onCreate(icicle);
Log.v(TAG, "onCreate: E");
setContentView(R.layout.main);
Log.v(TAG, "onCreate: X");
}
private static final String TAG = "test";
}
The Log class supports various levels (VERBOSE, DEBUG, INFO, WARN, ERROR, ASSERT) the low-level routine is Log.println(int priority, String tag, String msg). But typically the v, d, i, w, e and a convince routines would be used. So that’s half the game, the other half is to be able to see the output. For that you use “logcat”. In Eclipse if you goto menu “Window/Show View/other/Android/logcat” or if your in the Debug perspective it will be in “Window/Show View/logcat”. Apparently, its not very reliable in Eclipse and executing:
adb logcat
Allows you to see it from a command line, but in Eclipse the log also includes a Date stamp which makes it nice. I was able to get the Eclipse/logcat going by closing than reopening. Of course you mileage may very:) If you look at the links above it appears you can use ddms, but I haven’t used that yet.
Thanks for posting this info.
Comment by Bobby — February 4, 2008 @ 7:43 pm
Thanks for the information.
Comment by vijay — March 17, 2009 @ 5:46 am
So nice. thanks for this help.
Comment by Shyam — November 5, 2009 @ 2:43 pm
Thanks for the “adb logcat” tip – was getting fed up with Eclipse not showing anything there!
Comment by Rik Brown — November 24, 2009 @ 6:15 pm
Here is a tool to enhance your logcat experience
Windows link http://adrianvintu.com/blogengine/post/Colored-Logcat-Script-for-Windows.aspx
Linux link http://jsharkey.org/blog/2009/04/22/modifying-the-android-logcat-stream-for-full-color-debugging/
BR,
Adrian Vintu
Comment by Adrian Vintu — November 25, 2009 @ 2:55 am
Thanks! that works
Comment by Sundar — January 9, 2010 @ 4:44 am
Thanks for posting this nice info.
Comment by chintamani — February 15, 2010 @ 10:06 pm
I tried with adb logcat in command prompt,it didn’t work,but working fine in eclipse
Comment by chintamani — February 15, 2010 @ 10:08 pm