Log-File locations
There are several directories where logs (including those from crashes) might appear – not all of them are standardized (i.e. some may be ROM-specific). Some examples are:
/data/anr
“Application Not Responding” files/data/dontpanic
seems to be a standard location (AOSP), and contains some crash logs including traces/data/kernelpanics
/data/panic/panic_daemon.config
may point to other locations configured/data/panicreports
/data/tombstones
may hold severaltombstone_nn
files (withnn
being a serial, increased with every new file). As tombstones are placed for the dead, it is done here for “processes died by accident” (i.e. crashed) – and it is what is referred to as “core dumps” on Linux/Unix systems. However, not all apps create tombstones; this must be explicitly enabled by the developer.
There may be some more locations, but as most logging is done on tmpfs
(tmpfs is a common name for a temporary file storage facility on many Unix-like operating systems)
Log commands to use with a terminal app (or adb)
We are able re-direct them to a file (> filename.ext
) or pipe them through a filter (| grep search-for-this
):
1. Kernel log
dmesg
Run dmesg
from adb to get a live output of the Android kernel logs (just like a logcat shows live output of the system logs).
The kernel logs are important for troubleshooting hardware issues and other low level issues.
It doesn’t require filtering like a logcat, since it is a smaller log. Works without root.
$ dmesg <6>[82839.126586] PM: Syncing filesystems ... done. <7>[82839.189056] PM: Preparing system for mem sleep <4>[82839.189361] Freezing user space processes ... (elapsed 0.05 seconds) done. <4>[82839.240661] Freezing remaining freezable tasks ... (elapsed 0.00 seconds) done. <snip>
last kmsg
When the Android kernel crashes, it writes logs to last_kmsg.
This is like the last words of your Android device before it passes out. Android writes a quick log to last_kmsg before it reboots. last_kmsg helps to understand the reason of the issue.
There are a few other situations where Android writes to this log, such as kernel panics.
Right after force reboot, connect to ADB, and run:
adb shell cat /proc/last_kmsg > last_kmsg.txt
The last_kmsg log it only written to when a failure causes a crash, random reboot, or kernel panic (or a couple other things). It doesn’t always exist.
2. Logcat
Can e.g. specify what area you are interested in — radio, events, etc.
# logcat -b events I/am_create_service( 3457): [1085416560,nitro.phonestats/.widget.WidgetProvider4x1$WidgetUpdateService4x1,,3721] I/am_destroy_service( 3457): [1085416560,nitro.phonestats/.widget.WidgetProvider4x1$WidgetUpdateService4x1,3721] I/notification_cancel( 3457): [nitro.phonestats,4,0] <snip>
3. Getting device info
And tons of it: Device specifics, account information, services…
$ dumpsys Currently running services: LocationProxyService SurfaceFlinger accessibility account activity <snip> DUMP OF SERVICE account: Accounts: 1 Account {name=xxxxxxx@googlemail.com, type=com.google} <snip> $ dumpstate ======================================================== == dumpstate: 2012-08-18 23:39:53 ======================================================== Build: Gingerbread GWK74 - CyanogenMilestone2 Bootloader: 0x0000 Radio: unknown <snip> ------ MEMORY INFO (/proc/meminfo) ------ MemTotal: 487344 kB MemFree: 10436 kB <snip>
4. All-in-One = 1+2+3 = Bugreport
Make a big ball with everything together, from logcat to dumpstate:
$ bugreport > /mnt/sdcard/bugreport.txt
P.S.: Access to those information may require root.