XDA Basics: How to take logs on Android

XDA Basics: How to take logs on Android

Logs are very useful when a developer is diagnosing an error with a piece of software. So, as a user, when you complain to a developer about a problem with their Android app or an aftermarket firmware (custom ROM), they’ll ask you to submit a log to help them troubleshoot the issue. Android includes a number of logs that deal with different parts of the firmware, and there are a number of ways to collect those logs. In this guide, we’ll talk about the various common logs and how you can collect them on Android for bug reports.

Before we start, you should set up Android Debug Bridge on your computer as you might need ADB access for some of these logs. We have a great guide on how to set up ADB on any computer.

logcat

Kernel panic logs

Kernel panic logs are useful to figure out what happened during an unsuccessful boot. If you’re trying to run a custom ROM but your phone is stuck at the boot loop, you can collect kernel panic logs to help the ROM developer find out what went wrong.

A majority of Android manufacturers use upstream ‘pstore’ and ‘ramoops’ drivers to store kernel logs after a panic. Ramoops writes its logs to the RAM before the system crashes. With root access, these logs can be retrieved from:

/sys/fs/pstore/console-ramoops

The file name could be slightly different but it’ll be in the pstore directory. You can get it using ADB pull or any other way you want. For example:

adb pull /sys/fs/pstore/console-ramoops C:\Users\Gaurav\Desktop\filename

Driver messages

The log from the driver messages buffer can be used to diagnose issues with system drivers and why something isn’t working. On Android, you can use the ‘dmesg’ output to get these logs. You’ll need root access to get these logs though. Use the following ADB command to export the complete log.

adb shell su -c dmesg > dmesg.log

System logs

System logs are useful when something in the system throws an error. Android allows collecting system logs using Logcat. Log messages can be viewed in a Logcat window in Android Studio, or you can use the command line tool to pull them.

Several Android apps are also available in the Google Play store that allow easy access to these tools. We’ll talk about these apps later in this article. Moreover, several custom ROMs come with options in the Developers settings to collect the system logs.

To collect logs using ADB, use the following command. This command will export a continuous log, so use Ctrl + C to stop it.

adb logcat > logcat.txt

You can use the -d parameter to export the complete log in one go.

adb logcat -d > logcat.txt

If you want, you can also view or save the radio buffer using the following command.

adb logcat -db radio > radio.txt

If your device is rooted, you can use the Terminal app on the device itself to collect logs. To save a log using Terminal on your phone, type the following command so the log will be saved on your phone.

logcat -d -f /sdcard/logcat.txt

Android apps for collecting logs

Logcat Extreme

Logcat Extreme can help you read the logcat and dmesg outputs as well as record logs. It requires root access to show logs properly.

Logcat Extreme
Logcat Extreme
Developer: SCDevs
Price: Free

Logcat Reader

Logcat Reader is an open-source app that lets you read and save the system logs. It color-codes logs based on log priority.

Logcat Reader
Logcat Reader
Developer: Darshan Parajuli
Price: Free

LiveBoot

This app is not a proper logcat replacement, but it is cool in its own way and deserves a mention. The focus of this app is not to actually help you debug, but to give you an alternative boot animation that looks like it is out of a sci-fi movie.

LiveBoot replaces your device’s boot animation with logcat and dmesg outputs as they happen. Its output configuration includes logcat level, buffer and format selection, whether to show dmesg, and more. It requires root access as well as SuperSU version 2.40 or newer. You can find more about the app on its XDA thread.

[root] LiveBoot
[root] LiveBoot
Developer: Chainfire
Price: Free+

These are some of the ways you can collect logs on Android. If you’re looking for a way to gain root access on your Android phone, check out our detailed guide on how to root your phone.

About author

Gaurav Shukla
Gaurav Shukla

Gaurav has been covering technology for over a decade now. From blogging about Android to reporting the latest from the world of Internet giants, he has done it all. When he is not writing about the tech companies, he can be found binge-watching new TV series on the web.