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
Thanks for this, I was tearing my hairs out trying to understand why I couldnt see any logs in eclipse
Comment by codeIT — May 15, 2010 @ 1:52 am
Thanks for posting this. I couldnt figure out why my Log.i() statements weren’t showing up, and this was exactly why.
Comment by musicman3320 — July 27, 2010 @ 5:50 pm
Thanks for the article. I needed to work out where I can see it in Eclipse. There are some great tools in there for easily changing the log level. Do you know of a way to easily filter by the tag?
wink: I’m not sure in Eclipse but I believe you can do it using ddms.
Comment by Rick Pingry — August 4, 2010 @ 3:03 pm
You can use the verbose time option with adb logcat to show the time stamps –> adb logcat -v time
Comment by Andrew — August 7, 2010 @ 3:51 am
In the froyo release there is also -v threadtime which outputs the timestamp as well as the thread Id’s for the parent thread and the child thread, which can be handy.
Comment by wink — August 7, 2010 @ 9:03 pm
[...] does your logcat say? Debugging Tasks | Android Developers Android – application debug logging Wink Saville’s Blog __________________ Blundell Apps Android Support from Blundell Apps on Twitter Subscribe to our [...]
Pingback by Canvas, SurfaceHolder, and Panels. Oh My! - Android Forums — August 17, 2010 @ 12:09 am
Thank you!
This was exactly what I was looking for
Comment by Chris — September 7, 2010 @ 8:02 am
Thanks heaps – spent ages trying to find out how to see the log in Eclipse!
Comment by Chris — December 30, 2010 @ 9:53 am
As for now, Eclipse logcat window is working fine. java.util.Logger is supported (your project name is logged as tag) as well as System.out.
Thanks for posting the info. I found it very helpful!
Comment by cyberleopard — May 31, 2011 @ 12:55 pm
Log4j or slf4j can also be used in Android together with logcat. See the project http://code.google.com/p/android-logging-log4j/.
Comment by Rolf Kulemann — December 23, 2011 @ 2:15 am