How to save Android application log to file on physical device?

I want to know why my Android application service is sometimes omitted (regardless of whether it kills it or crasch), and therefore I want to save the log file on my phone. How can I do that?

+4
source share
1 answer

In principle, you have two possibilities, and, as a rule, the first should help you find the cause of the failure without encoding, because logcat should show the error that led to the termination of the service.

1) Using the logcat command

With Log.i("your tag", "output text") , you can intercept these messages using the Android Eclipse plugin or by calling adb logcat from the command line using your Android device and your service.

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

2) Write to stdout

Using the System.out.println("...") command, you can configure your 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 need to distribute a large number of debug output messages to your application, mainly at critical points.

Good luck finding the error!

+3
source

Source: https://habr.com/ru/post/1341100/


All Articles