144

There is a lot of interesting stuff in the Android system log, that is helpful in many ways

  • find root causes of problems
  • identify misbehaving apps

How can I view and examine the Android log?

0

4 Answers 4

82

Android 4.1 and newer

The preferred way is to download the SDK and use adb logcat (requires to activate "developer options" on device).

There are apps available for viewing the full system log, however they only work on rooted devices or require issuing a manual command via adb to make them work. For more information view see this question.

Android 4.0 and older

You can either download the SDK and use adb logcat or get Logcat Extrem from the Google Play Store, which shows the log directly on your phone.

4
  • 4
    Alternatively, you can use Terminal Emulator with command "logcat > /sdcard/log.txt" for continuous writing of the log to a file on the SD Card. This can help figure out issues with random reboots.
    – Chahk
    Commented Oct 11, 2011 at 15:07
  • Good point. Some phones tend to spam the log full of trivial information, so if you wish to minimize the filesize and data to go through check out the section "Filtering Log Output" on developer.android.com/guide/developing/tools/adb.html#logcat Commented Oct 11, 2011 at 16:31
  • LogCat Apps doesn't work anymory with JellyBean. Google changed the Android API, apps don't have the permission anymore to read logs from other apps than their own.
    – Leandros
    Commented Nov 11, 2012 at 13:39
  • 1
    I have created a simple utility to collect logs from a PC: gist.github.com/hrj/5983971
    – HRJ
    Commented Jul 16, 2013 at 18:36
72

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).

  • /data/anr: Some trace files seem to get here (Dalvik writes stack traces here on ANR, i.e. "Application Not Responding" aka "Force-Close"; see e.g. log excerpts here)
  • /data/dontpanic seems to be a standard location (AOSP), and contains some crash logs including traces (see e.g. viaForensics and StackOverflow)
  • /data/kernelpanics is another location -- not having had any "kernel panic" on my Android devices, I saw no content there yet.
  • the /data/panic/panic_daemon.config may point to other locations configured -- on my Droid 2 it mentions /sdcard/panic_data/
  • mentioned Droid 2 also has a /data/panicreports directory (empty here)
  • /data/tombstones may hold several tombstone_nn files (with nn 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 (see Debugging Android Core Dumps).

There may be some more locations which escaped me; but as most logging is done on tmpfs, these data are lost with a reboot, and would not match the OPs question.

Log commands to use with a terminal app (or adb)

Several commands can get you tons of information. For most of them, it is to recommend to re-direct them to a file (> filename.ext) or pipe them through a filter (| grep search-for-this):

Kernel log

The following 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>

Logcat

Here you can e.g. specify what area you are interested in -- radio, events...

# 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>

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 {[email protected], 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>

All-in-One

Make a big ball with everything together, from logcat to dumpstate:

$ bugreport > /mnt/sdcard/bugreport.txt

I'm pretty sure you really want to redirect that last command... xD

Something about permissions

P.S.: Naturally, access to those information may require root, as most of the sources are located on internal storage.

3
  • To get some more insights into adb logcat commands see here.
    – testing
    Commented Apr 27, 2016 at 16:03
  • Or just check our logging tag-wiki @testing – that has even more references :)
    – Izzy
    Commented Apr 27, 2016 at 20:47
  • 1
    For anyone else like me who is new to Android, in order to run the above commands you need to first run $ adb shell to connect to the device via a terminal. (Of course, ensure your device is connected to your computer and that USB debugging has been turned on.)
    – Derek Lee
    Commented Jan 7, 2021 at 1:07
10

A method without root, that works even with new Android versions:

Prerequisites:

  • Linux, Windows or Mac
  • USB cable for your device
  • Android Device

Instructions:

  1. Install your device driver for using adb. Everything you need will you find here
  2. Download adb executable for your OS. It is part of the Android SDK, but you might be able to find the adb executable individually.
  3. Connect your android device.
  4. Enable the developer options.
  5. Enable USB debugging.
  6. Open a command promt (windows) or terminal (linux / mac). How to do it: On Windows: windows + r > enter "cmd" (without quotes) > click enter | On Linux: You don't know how to open a terminal? LOL | On Mac: Type Terminal into Spotlight and open it
  7. CD to the directory where the adb executable is located. On Windows: Go to the directory where you downloaded the adb executable, Shift+Right Click and select "Open Console" (or similar) | On Linux / Mac: Rightclick in the directory and select "Open Terminal here" (or simply CD into the directory)
  8. Type in your cmd/terminal: adb devices to verify your device is properly connected.
  9. If your device is properly selected, type in adb logcat to show the mighty and magic logcat aka stacktrace.
  10. Reproduce your error (or whatever) on your device.
  11. Right after, paste the whole cmd / terminal window into a paste-service like http://pastebin.com/ and send it to us.

(Mostly copied from Leandros)

1
-2

It is located in /sdcard/bugreports.

2
  • 3
    I've never had such a folder on my phone ... is this specific to a manufacturer or device? Commented Dec 19, 2011 at 23:44
  • 4
    From Logcat - CyanogenMod Wiki: You can use a magic key combination to create a bugreport file in /sdcard/bugreports. So this seems to be a) a bit specific (probably to CM), and b) not the answer to the question, as the OP looks for "automatically generated" ones.
    – Izzy
    Commented Aug 18, 2012 at 23:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .