Logcat won't display Log.d messages
Asked Answered
K

6

18

I'm developing an Android application and I would like to have some way to print debug statements as my code runs. Fortunately for me, Logcat was able to print out Log.d messages when I run my application on an Android 2.3.3 (API 10) emulator.

However, when I tested the same exact application on a physical device (Samsung Galaxy S4 Android 4.2.2) I was unable to see anything other than dalvikvm and AndroidRuntime messages.

com.android.internal.os.RuntimeInit <<<<<<
07-28 04:49:24.165: DEBUG/AndroidRuntime(6378): CheckJNI is OFF
07-28 04:49:24.165: DEBUG/AndroidRuntime(6378): setted country_code = USA
07-28 04:49:24.165: DEBUG/AndroidRuntime(6378): setted countryiso_code = US
07-28 04:49:24.175: DEBUG/AndroidRuntime(6378): setted sales_code = VZW
07-28 04:49:24.175: DEBUG/AndroidRuntime(6378): readGMSProperty: start
07-28 04:49:24.175: DEBUG/AndroidRuntime(6378): readGMSProperty: already setted!!
07-28 04:49:24.175: DEBUG/AndroidRuntime(6378): readGMSProperty: end
07-28 04:49:24.175: DEBUG/AndroidRuntime(6378): addProductProperty: start
07-28 04:49:24.185: DEBUG/dalvikvm(6378): Trying to load lib libjavacore.so 0x0
07-28 04:49:24.185: DEBUG/dalvikvm(6378): Added shared lib libjavacore.so 0x0
07-28 04:49:24.195: DEBUG/dalvikvm(6378): Trying to load lib libnativehelper.so 0x0
07-28 04:49:24.195: DEBUG/dalvikvm(6378): Added shared lib libnativehelper.so 0x0
07-28 04:49:24.385: DEBUG/AndroidRuntime(6378): Calling main entry com.android.commands.pm.Pm
07-28 04:49:26.978: DEBUG/AndroidRuntime(6378): Shutting down VM
07-28 04:49:26.988: DEBUG/dalvikvm(6378): GC_CONCURRENT freed 157K, 21% free 627K/788K, paused 1ms+0ms, total 4ms
07-28 04:49:26.988: DEBUG/jdwp(6378): Got wake-up signal, bailing out of select
07-28 04:49:26.988: DEBUG/dalvikvm(6378): Debugger has detached; object registry had 1 entries
07-28 04:49:27.458: DEBUG/AndroidRuntime(6420): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
07-28 04:49:27.458: DEBUG/AndroidRuntime(6420): CheckJNI is OFF
07-28 04:49:27.458: DEBUG/AndroidRuntime(6420): setted country_code = USA
07-28 04:49:27.458: DEBUG/AndroidRuntime(6420): setted countryiso_code = US
07-28 04:49:27.458: DEBUG/AndroidRuntime(6420): setted sales_code = VZW
07-28 04:49:27.458: DEBUG/AndroidRuntime(6420): readGMSProperty: start
07-28 04:49:27.458: DEBUG/AndroidRuntime(6420): readGMSProperty: already setted!!
07-28 04:49:27.458: DEBUG/AndroidRuntime(6420): readGMSProperty: end
07-28 04:49:27.458: DEBUG/AndroidRuntime(6420): addProductProperty: start
07-28 04:49:27.468: DEBUG/dalvikvm(6420): Trying to load lib libjavacore.so 0x0
07-28 04:49:27.478: DEBUG/dalvikvm(6420): Added shared lib libjavacore.so 0x0
07-28 04:49:27.478: DEBUG/dalvikvm(6420): Trying to load lib libnativehelper.so 0x0
07-28 04:49:27.478: DEBUG/dalvikvm(6420): Added shared lib libnativehelper.so 0x0
07-28 04:49:27.649: DEBUG/AndroidRuntime(6420): Calling main entry com.android.commands.am.Am
07-28 04:49:27.659: DEBUG/dalvikvm(6420): Note: class Landroid/app/ActivityManagerNative; has 169 unimplemented (abstract) methods
07-28 04:49:27.719: DEBUG/AndroidRuntime(6420): Shutting down VM
07-28 04:49:27.729: DEBUG/dalvikvm(6420): GC_CONCURRENT freed 157K, 20% free 666K/828K, paused 0ms+1ms, total 3ms
07-28 04:49:27.729: DEBUG/jdwp(6420): Got wake-up signal, bailing out of select
07-28 04:49:27.729: DEBUG/dalvikvm(6420): Debugger has detached; object registry had 1 entries

I'm not exactly sure what is going on since Logcat is correctly targeting my physical device, it shows up on adb devices, and USB Debugging is on.

I've tried using Log.e but that had no effect on the output.

I even set android:debuggable="true" in AndroidManifest.xml.

Is there something I'm missing here? Why won't Logcat display my debug messages when running my app on my physical device?

EDIT: I tried the same app on a Android 4.2.2 emulator and Logcat works as expected with the emulator, but there's still the problem with Logcat through the USB device. Instead of the verbosity of a normal Logcat printout, the block I posted is the only thing I see on the Verbose log level.

Kylakylah answered 28/7, 2013 at 12:1 Comment(5)
could You give us an exampe how do YOu have defined the Log in code? Also, have YOu tested it on an emulator with 4.2.2?Monaghan
Do you have a filter on logcat? Which IDE do you use?Intoxicating
@Monaghan imported Log from android.util.Log, and I used it like Log.d(TAG, "Debug message here"); @Intoxicating I don't have a filter on logcat -- that is the entire output from Logcat. I use IntelliJ IDEA 12.1.4.Kylakylah
How did you resolve it? I'm facing same kind of issue.Yoshida
@Yoshida see my answer, I managed to solve this problem.Chemo
P
37

It might because of some phones disabled log to enhance performance.

For example, my phone HUAWEI P9 lite, i have to do the following steps to make Log.d works:

  1. Dial *#*#2846579#*#*
    • The number might vary, you should do some search to get secret code for your phone.
  2. Come to ProjectMenu page
  3. Click Background Settings
  4. Click LOG Settings
  5. Check AP Log.
  6. For unknown reason, it automatically checked all logs when reopen LOG Settings.

enter image description here

[UPDATE]

Just now it happen again after I pull from git, adb shell shows this:

open '/dev/hwlog_switch' fail -1, 13. Permission denied
log switch off, only log_main and log_events will have logs!

I test with new project and it got log, only this old project has issue. I tried rebuild the app, re-enable the log steps above, and even reboot phone, but still no luck.

Then I uninstall the app (Or all relevant productFlavors apps) in phone and reinstall, the log was back.

Perihelion answered 24/6, 2016 at 8:12 Comment(5)
Very useful information that I never know before. Thanks.Lalonde
You are the man! I spend hours trying to figure out why I didn't see any debug logs. And all I could find were instructions on how to change the log level in logcat in android studio.Berna
this code allow me to use log.wtf but not log.d. it is sufficient for meKarlenekarlens
S9: Developer Options -> "log output level" is what you're looking forSyrup
Honestly you helped me, i have Huawei p8 lite and secret number is the same. Within 20 days contract is gonna terminate so i need to choose new phone, any suggestions :D ?Furze
H
14

On some models you have to go to the developer options, and select "Allow all", on "Advanced logging".

The following screenshot is from my Meizu MX 4 Pro:

enter image description here

Hensel answered 15/3, 2017 at 23:17 Comment(3)
For Meizu MX4 with Flyme 6.1.0.0 you need to go to Developer Options -> Performance optimalization -> Advanced logging; I took me ages to find it...Magnificence
Meizu m2(Flyme 6.1.0.0G) too Developer Options -> Performance optimalization -> Advanced logging-> set "allow all"Pye
It helps for Meizu 6 pro plus.Gurias
C
1

Did you have enabled USB debugging for logcat ? (if your physical device is connected by USB cable). Go to "settings", then "applications", then "development", then check "USB debugging".

Then it should appear in DDMS. Just select it to debug/see logs.

Consciousness answered 28/7, 2013 at 12:8 Comment(1)
I do have USB debugging enabled and my device does show up in DDMS. The only problem is that the log that pops up is exactly what I posted in the question.Kylakylah
U
1

Today, I faced the same issue. Nothing worked for me as mentioned solutions. But what worked for me is in Android Studio Right side at the bottom as mentioned in the image. Select the option as mentioned in the image. After that everything was working as expected. Now posting my solution it may help others.

enter image description here

Hope that helps others

Undertint answered 8/12, 2017 at 8:55 Comment(0)
M
0

Maybe not an answer, but need to show pictures. Try to set a Filter for Your TAG like this:

enter image description here

and select verbose option:

enter image description here

does this help?

Monaghan answered 29/7, 2013 at 11:44 Comment(1)
Thanks for posting pictures, but I did the equivalent in Intellij IDEA and the filter shows nothing.Kylakylah
C
0

You need to set logging (to the desired level) through the adb shell as follows:

  1. Navigate to the platform-tools in your android sdk folder.
  2. Open the adb shell using ./adb shell for linux/mac/windows powershell or just adb shell for windows cmd.
  3. Issue the following commands:

     stop
     setprop log.tag.MYTAG VERBOSE
     start 
    
Chemo answered 18/11, 2013 at 6:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.