I know that the boot up log can be obtained by pulling out contents of kmsg
or dmesg
through ADB
.
But I\'m not aware of how to retriev
One work around I found for collecting shutdown logs in Android is to run adb pull /proc/kmsg C:\Logs.txt
on the host PC and then switch off the device. You will get the logs till the USB communication between the host and the device snaps! I know this is only one case out of the numerous shutdown scenarios but I haven't found satisfactory answers for other cases!
Look in some locations such as these:
/proc/last_kmsg
/data/tombstones/
/data/dontpanic/
/data/system/dropbox/
(This list isn't strictly kernel logs, including framework and application logs too, which are also sometimes of interest)
TL;DR:
Run command through adb that copies logcat and proc/kmsg to a file and keep it running even when adb disconnects with nohup
, disown
or setsid
. Probably needs busybox, needs root and adb root, too.
setsid cat proc/kmsg > /sdcard/kmsg.txt &
and
logcat -v long -f /sdcard/logcat.txt
(somehow only works without setsid
)
Or add normal copy commands to some startup script.
/TL;DR
You can constantly copy proc/kmsg
and logcat
to a file on your android device or a microSD card to get the logs even after adb disconnects.
You need root access and adb root access for this to work. For the latter, use the setting in the developer options if you have a custom rom or the adbd insecure app.
After using adb shell
to get your android shell, type su
to get superuser access.
Then you not only need to put an ampersand (&
) after the command but also make sure that the command keeps running after adb disconnects. That is done by nohup
, disown
or setsid
(see here for usage).
If it doesn't work because you don't have these commands, you need to install busybox.
See my question here.
See here for how to get logcat and kernel logs and print it to some file or merge it. See developer.android.com/tools/help/logcat.html for parameters for the logcat command.
In the end you could have a command like setsid cat proc/kmsg > /sdcard/kmsg.txt &
for the kernel messages.
For logcat you could have one of the following commands: logcat -v long -f /sdcard/logcat.txt
or logcat -v long > /sdcard/logcat.txt
I don't know why, but sometimes it didn't work with setsid
and just didn't copy continuously but stopped shortly after executing the command. In these situations, it also showed up when entering jobs
, which it didn't otherwise. Then it just worked without setsid
, it stayed alive after disconnecting and reconnecting. I guess you must just try when the file does keep getting larger. If someone figured out why it is behaving like it is... let me know and I'll edit the answer.
Probably adding the commands to a startup script could be a solution for some, too.
Hope this helps.
fightcookie
Newer phones do NOT use any of these locations so if you're reading this article then as of now
The kernel crash logs are now in /sys/fs/pstore instead of /proc/last_kmsg