Logcat won't display Log.d messages

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.


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