When you’re fiddling with a mobile device’s firmware, and changing it’s binaries, the device can turn a little bit unstable (at best). This instability can translate to programs not doing what they’re supposed to do, programs closing forcibly, or even crashing the whole system if it was a core component that was changed.
We can always improve a situation like crashes, force-closing applications, and the like by tracing the steps that were followed by the system. A record of these steps, if the applications and/or systems are developed correctly, are kept on the logs.
On Android, the logs are non-persistent, meaning that they don’t stay with you and are wiped on some circumstances, e.g. a reboot. This non-persistency has a couple of reasons, to my understanding:
- End-users won’t need anything else than the short-term logs (as the system is delivered stable)
- The phone’s storage is limited, so storing logs could yield some undesired storage problems.
The definition of “short-term” is a bit debatable on this case, but by this I mean that normally an end-user won’t need a log that transcends a reboot, or a log of the activities of 10 hours ago.
So, here are two ways (not the only ones) to have these logs available for you persistently, in case you need to find out what’s wrong on your android device, should you, like me, poke stuff in and out of the phone’s OS.
Things you need are provided by the tools you needed to root your phone, except probably for the Android Debug Bridge (adb) , which you can get if you download the Android SDK tools . I assume you put the path to adb.exe on your PATH environment variable.
On both scenarios you should be on your computer and have your phone’s plugged in at least when you boot the phone. Otherwise where else would you be fiddling with your phone’s OS? Also, please note that the logging stops when the phone crashes, so after a reboot you have to start logging again (hopefully after collecting last time’s logs).
Log file on your phone’s sdcard
Use this command while connected to your computer just after a reboot, and after that you can just unplug it and your logs will be saved on your /sdcard with names that start with “logcat.txt”, I often use this command for my day to day activities when “random” reboots occur.
adb shell nohup logcat -f /sdcard/logcat.txt -r 1024 -n 60 -v time &
Log file on your computer
Use this command while connected to your computer just after a reboot, but you have to stay plugged in so that the log stream is redirected to the chosen file (in this case “fileonyourcomputer.txt”), I find this command very useful if I KNOW how to re-create scenarios.
adb logcat > fileonyourcomputer.txt
I hope this helps you or at least give you a useful idea. Feel free to comment, question and/or suggest on the comments section.