How do I save the Android application log to a file on a physical device?

I want to know why my Android application service occasionally fails (whether the operating system kills or crashes), so I want to save log files on my mobile phone. What should I do?

resolvent:

Basically, you have two possibilities. Usually, the first one should help you find the cause of the crash without coding anything, because logcat should display the error that caused the end of the service

1) Using the logcat command

With log. I ("your tag", "output text"), you can use the Android Eclipse Plug-in to intercept these messages, or call ADB logcat from the command line to connect to the Android device and run the service

See also http://developer.android.com/guide/developing/tools/adb.html#logat

2) Write stdout

Use the system.out.println ("...") command to configure the device to write stdout to a file:

adb shell stop
adb shell setprop log.redirect-stdio true
adb shell start

See also http://developer.android.com/guide/developing/tools/adb.html#stdout

Obviously, you must propagate a large number of debug output messages on your application, mainly at key points

Good luck finding mistakes!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>