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!