android java log.d,LogCat中不会显示Log.d消息

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.

解决方案

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

Navigate to the platform-tools in your android sdk folder.

Open the adb shell using ./adb shell for linux/mac/windows powershell or just adb shell for windows cmd.

Issue the following commands:

stop

setprop log.tag.MYTAG VERBOSE

start

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值