38

when I'm using the Android emulator I can do "adb logcat" to see output messages (log / system.out.println) originated from my code. It also shows the stack trace of exceptions which happen during execution.

But, when I'm using a real phone, "adb logcat" does not do / show anything.

I also tried "adb -d logcat" which also does not display anything.

Is there any way to get it working with the real phone?

Thanks.

UPDATE:

I just tried "adb -s ? logcat" ('?' is the serial number of the device) and also got no results.

I tried another "adb" command to see if anything was working: "adb -s ? bugreport". This printed a lot of stuff. Example: "Memory Info", "CPU Info" and some Java specific things. So it seams that some stuff is working.

12 Answers 12

73
  1. Enable USB debugging on your device.

  2. Connect the device to computer

  3. Use these commands:

Get the "device id"

adb devices

example:

$ adb devices
List of devices attached
5856423841563398    device
emulator-5554   device

To specify the device when using logcat

adb -s "device id" logcat

example:

$ adb -s 5856423841563398 logcat
--------- beginning of crash
03-31 15:56:51.174 13547 13547 E AndroidRuntime: FATAL EXCEPTION: main
0
18

Don't forget to check Settings -> Applications -> USB debugging. Then

 $ adb -d logcat

will show log messages.

3
  • The USB debugging was already activated on the cellphone... no results in the logcat. Other ideas? Thanks.
    – MyName
    Commented Sep 15, 2010 at 12:09
  • Got same problem under Eclipse solved by unplug/replug the real device and just click on the device in the "devices" tab. Then logcat shows what needs, with or without filtering.
    – hornetbzz
    Commented Nov 6, 2012 at 10:55
  • 1
    Great, so how do I look at only the logs from my application? Commented Jun 30, 2014 at 21:19
12
  1. Get list of devices:

    adb devices

You will get this:

List of devices attached
emulator-5554   device
0123456789ABCDEF        device
  1. Run log with parameters like this:

    adb -s "0123456789ABCDEF" logcat MyTag:D *:S

where "MyTag" is tag used in Log.d("MyTag", value) or you will get too many text.

0
6

This is the best way to use LogCat via command line:

adb logcat -v time > log.txt
2
  • This may seem like an obvious suggestion, but it would be helpful to explain what -v does, and in what format the time should be specified. Commented Mar 26 at 7:08
  • the -v option is used to specify the format of the log messages that will be displayed. It stands for "verbosity" and allows you to choose different levels of detail for the log output.
    – Mr T
    Commented May 14 at 10:09
3

you can do "adb -d logcat". This should work.

0
3
  1. Enable USB debugging in your device.
  2. Connect your device to computer
  3. Open Android Studio
  4. Click on View/Tool Windows/Logcat (or Alt+6)
  5. Select your device on the top left combo box

enter image description here

0
2

have you installed ADB drivers for the device?

What does adb devices return?

Emulators are named like emulator-5554 etc. If your device is properly installed you should see it too. The name depends on which manufacturer you are using.

If you don't see your device, the drivers are not installed correctly. Do some searches for "adb install drivers" on Google. Here's a hit that might do it for you: http://forum.xda-developers.com/showthread.php?t=502010

3
  • Running "adb devices" displays the device id, as expected.
    – MyName
    Commented Sep 14, 2010 at 10:52
  • Have you tried starting the ddms standalone application? Can you see your device in the devices list?
    – Key
    Commented Sep 14, 2010 at 11:02
  • Hello. Yes the device (real phone) appears listed when the "ddms" application is executed.
    – MyName
    Commented Sep 15, 2010 at 12:05
1

Try downloading Catlog to your phone

0
1

You probably need to activate logging on your mobile device too.

In the case of my Huawei device, I need to enter the phone number: ##2846579##

to get into a service menu. From there I could activate logging. Not sure what device you are using, but probably there is some service menu there too.

Once done, reboot and try again with adb -d logcat

Cheers Christian

0

Had the same issue but added a filter in the logcat and only give him a name and set log level to "verbose". You can try that.

I can't see the complete message of some exceptions if the message are to long. Scrolling doesn't function very well.

(Using Eclipse)

Jelmert

1
  • I created a named filter and set it to "verbose": still not working. Other ideas? Thanks.
    – MyName
    Commented Sep 21, 2010 at 14:00
0

On the windows command/Linux shell, issue the command below,

adb devices 

if the device is not listed in result, then install "APK installer", which can help install the adb driver in your windows machine. Link is below:

http://apkinstaller.com/downloads/

Check the listing again with the command above in the shell/cmd, and if the device is listed then Log Cat will surly work.

After that you can try:

adb -d logcat

Check the tutorial on YouTube: https://youtu.be/vO0Wf0E6Z4o

Happy Coding :-)

-2

Enabling logcat on the Huawei U8185: http://mjanja.co.ke/2012/08/enabling-logcat-on-the-huawei-u8185/

Not the answer you're looking for? Browse other questions tagged or ask your own question.