LightBlog

vendredi 23 juillet 2021

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 Logcat Extreme menu Logcat Extreme log

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 (Free, Google Play) →

Logcat Reader

Logcat Reader Logcat Reader Dark

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 (Free, Google Play) →

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 options LiveBoot output

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 (Free+, Google Play) →


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.

The post XDA Basics: How to take logs on Android appeared first on xda-developers.



from xda-developers https://ift.tt/3kJT7UA
via IFTTT

Aucun commentaire:

Enregistrer un commentaire