rajan sthapit
rajan sthapit

Reputation: 4354

How do I view Log messages in Android?

I am trying to debug my android application using log messages. When I use System.out.println and Log.i and run the android application,I cannot see the debug message in either console or Logcat. If I have to get the debug messages do I have to run the android app in debug mode

Upvotes: 3

Views: 4863

Answers (4)

Michał Klimczak
Michał Klimczak

Reputation: 13154

If you're using Eclipse make sure that:

  1. You have Debugging enabled in your device (or that you use emulator),
  2. Your device is connected properly - it should show up in the Devices view. If you don't have this view get it from Window->Show View->Devices,
  3. You've SELECTED your device in the Device View (simply click on it),
  4. You don't have the LogCat paused and no filter is enabled - All messages (no filters).

Upvotes: 0

MAC
MAC

Reputation: 15847

sometime you may not select the emulator

and another way is to

restart your eclipse i also have faced this problem many times

Upvotes: 0

Suvam Roy
Suvam Roy

Reputation: 1280

from eclipse goto window -> open perspective -> other -> select DDMS. And then run your app. And then select your running device from DDMS. If it is not resolved your problem, restart your eclipse without closing your emulator and then flow the same above steps. Njoy,

Upvotes: 1

Thomas Dignan
Thomas Dignan

Reputation: 7102

You do not need to run your app in debug mode to see log messages.

In order to see the log messages, you only need to have usb debugging enabled on your phone, the adb drivers for your device installed, and a copy of the android developer tools. It sounds like you have the above things, so I will suggest some steps for troubleshooting this.

Don't use System.out.println, because it does not allow you to specify a tag. Make sure that you set a good tag for your log messages. Once all of the above is confirmed, attempt to view the log message in eclipse's logcat view. Create a filter with the tag you are using because many messages will print and it may be difficult to find yours. You can also filter by application by using the name of your application's package.

If you have tried all this and you still can't see log messages, try running:

adb kill-server

and

adb start-server

If no luck, try restarting eclipse.

Confirm your device is plugged in!

If none of this is working, you can also run ddms from the sdk tools which is a bit more reliable.

Finally if that doesn't work, you can simply issue an adb logcat on the command line. If you have multiple devices, you can list them with adb devices and resolve the device or emulator with -d for the only connected device, -e for the emulator, or -s serialno to resolve otherwise.

There are also tools that will allow you to view the logs on your device, such as alogcat

Upvotes: 1

Related Questions