How to View and Examine Android Logs?

Yoodley is reader-supported. When you buy through links on our site, we may earn an affiliate commission.

If you are looking to learn how to obtain and examine android logs, this is just the post for you. Log analysis is important to recognize bugs and obstructions in an application-in-making which is provided by a set of logs. Let’s start with the basics first, however.

Different types of Logs and what they contain

Android has a centralized system of all logs, and these logs are available in different categories, which allows the users and the application programmers to look for a particular filter for the log statement. 

The log analysis helps the developers to find the fault in a log and develop the application from time to time. Different types of logs available in Android are Application log, System log, Event log, Radio log.

What Each Log Type Contains:

Application log:

This mainly contains log messages from all the different types of applications running on an android device.

The android.util.Log class method is used to write messages of different priorities in the log.

System log: 

Messages or logs in this category are set with different priorities from the android logs—the Android.util.Slog class is used to write messages of the system log.

Event log:

It consists of binary tag codes that are followed by binary parameters. 

The event log messages are created by Android.util.EventLog class which help in creating binary-formatted log messages. These message tags are stored at: /system/etc/event-log-tags.

Radio log:

It has all the radio and phone-related information, like network info and signal strength. 

 

How to view and examine Android Logs?

In most android devices, root access is required for viewing android logs and also to examine them. These logs are located in the internal storage, and in order to access the internal storage sources, root access is required. 

Android devices with older versions or below 4.0, can use the SDK or ADB logcat or any other log viewer available on Google play that directly shows logs on your phone.

Android devices with version 4.1 or above require SDK and ADB logcat to view the full system logs, but they require rooted devices to work, or they can work by issuing a manual command via ADB.

File Locations where you can view Android Logs

Since there is a variety of logs available on your Android device, they are located at different locations, and it is at times difficult to find a particular log through several directories. Here are some common file locations where you can find some important logs:

  • /data/anr: Here, you will find Dalvik’s written stack traces.
  • /data/dontpanic: It has standard crash logs and traces.
  • data/panic/panic_daemon.config: It points to another configured location.
  • /data/tombstones: It has several tombstone_nn files, which are also referred to as “core dumps” on Linux systems.

 

How to obtain Android logs on:

Windows:

These are steps that you need to follow in order to obtain Android logs on your Windows PC.

  • Install the latest Android SDK on your Windows PC.
  • Then install the Android Platform Tools.
  • Connect your android device to your Windows PC with a USB cable.
  • Open a new command prompt session, change the working directory to the path where Android SDK is installed (cd [path where Android SDK resides]/platform-tools).
  • First, run the following command adb.exe kill-server
  • Next, run the command to list the devices connected to your PC. Note down the device ID of your device. 
  • Run adb.exe logcat -v threadtime [device id] > C:\android-debug.log

Enter the device id obtained in the previous step in place of [device id].

  • Perform any actions on your Android device.
  • Press Ctrl + C on the command prompt window to stop the ADB process.
  • The debug data can be viewed from the c:\android-debug.log file.

 

Mac:

On a Mac device, follow the steps given below;

  • Download and install Android SDK. Once the installation completes, Android SDK will launch automatically. Select and Install Android Platform Tools.
  • Connect your Android device to your Mac device via USB cable.
  • Open a new Terminal, change the working directory to the path where Android SDK is installed (cd [path where Android SDK resides]/platform-tools).
  • First, run the following command

./adb kill-server

  • Next, run the command to list the devices connected to your PC. Note down the device ID of your device.

./adb devices

  • Run,

./adb logcat -v threadtime [device ID] > /tmp/android-debug.log

Enter the device id obtained in the previous step in place of [device id].

  • Perform any actions on your Android device or reproduce any issue you encountered.
  • To stop the ADB process, press Ctrl + C on the Terminal window.
  • The debug data can be viewed from the android-debug.log file.

 

How to view Android Logs without rooting your device?

There are many users who don’t want to root their device as it might lose the warranty of the device provided by the manufacturers. It is also not a completely safe and easy process, so for those not wanting to root their phone, here are some processes of viewing Android logs that do not require rooting:

These methods will work on almost every android version. The required prerequisites are:

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

 

Instructions

  1. Install required device drivers for using ADB.
  2. Download ADB that is executable on your OS. Although it is a part of Android SDK, you can also get an ADB executable individually.
  3. Now connect your android device.
  4. Enable USB debugging on your android device.
  5. Open a command prompt (Windows) or terminal (Linux / mac). (On Windows: windows + r > enter “cmd” (without quotes) > click enter | On Mac: Type Terminal into Spotlight and open it.)
  6. 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: Right Click in the directory and select “Open Terminal here” (or simply CD into the directory)
  7. Type in your cmd/terminal: ADB devices to verify your device is properly connected.
  8. If your device is properly selected, type in ADB logcat to show the mighty and magic logcat aka stacktrace.

 

FAQs

Q. How to Fix “Android studio logcat nothing to show” in Android Studio?

A. If the Android Studio shows nothing in the logcat, it may happen because of the small Logger Buffer Size, or there might be some issue with Android Studio itself. In order to fix this issue, check if you are using the latest and updated version of Android Studio. Reboot your android device and try again. If the problem still persists following the given solutions;

Android Debug Bridge (ADB) use libusb backend

  1. Android Studio > Preferences > Debugger > Android Debug Bridge (ADB) enable “Use libusb backend”
  2. Restart android studio with Invalidate cache.

Increasing Logger Buffer Sizes

  1. On your android device, go to Settings –> Developer Options –> search for Logger buffer Sizes ( change it to 1M or Bigger size ), and then your android studio IDE will show data in Logcat.

 

Q. How to capture Android Logs?

A. Problems like unusual bugs in the Android Logs showing error, debug messages and other bugs isn’t something new. Whenever an app is developed, built aur updated, it may have bugs that need to be fixed when found.

Here are steps to create a logcat file which you can attach to a bug report,

For a computer 

  1. You must have ADB installed on your device; if not, then you must install it before moving further.
  2. Open Command Prompt (Windows) or Terminal (Linux/macOS).
  3. Connect your device via cable or over WiFi
  4. Type ADB logcat -d > logcat.txt. This will save the log to logcat.txt.
  5. Additionally, the radio buffer can be viewed or stored with logcat. If needed or requested, type ADB logcat -db radio > radio.txt to save it to radio.txt.

On your device:

To use this method, your device must be rooted, and this process is only supported up through LineageOS 16.0; users with 17.1 or above version need to follow the computer process.

  1. Open the Terminal app (you can enable the built-in terminal app in Developer options).
  2. Type su and confirm root access – you may have to turn on root access for apps in Developer options.
  3. Type logcat -d -f /sdcard/logcat.txt. This will save the log to /sdcard/logcat.txt.
  4. Additionally, the radio buffer can be viewed or stored with logcat. If needed or requested, type logcat -db radio -f /sdcard/radio.txt to save it to /sdcard/radio.txt.

 

Q. How do I capture Crash Logs on Android?

A. Capturing crash logs or bugs of an android to debug and fix the errors is quite easy.

Follow the steps given below to capture logs on Android;

  1. Connect your android device with a USB cable to your PC with ADB installed to it.
  2. Open CLI (Terminal on a Mac) (Start –> Run –> CMD on Windows).
  3. Navigate using the terminal to the Android SDK directory (for example, C:\Program Files\Android\android-sdk\platform-tools).
  4. Type ADB logcat.
  5. Check for the logs that you want to create, examine and fix.
  6. If you want to save the output to file, run: ADB logcat >/$*some-folder*/android-debug.log 

 

Q. Should I delete log files on my Android device?

A. A log has a definite limit up to which it can grow, and after that, the older logs are pruned to keep the log from growing further. And in some android devices, the logs are kept only in memory, and sometimes the logs are stored on a disk. You can delete the logs or clear them, but immediately a new log message will appear the moment you execute the command.

 

Q. How to view android logs on a Samsung device?

A. Getting the android logs on a Samsung device is easier and fast with the secret code *#9900#. To get to the android logs in a Samsung device following the given steps;

  1. Open the Phone app on your device and type: *#9900#
  2. Depending on how many detailed logs you would like to get, change Debug Level and Silent log options (by default Debug Level is Disabled/LOW and Silent Log is turned Off)
  3. Click on Run dumpstate/logcat/modem log
  4. Click Copy to sdcard(include CP Ramdump). It is an important step because, by default, collected logs will be stored in the /data/log directory, which is under root permissions, so you can’t access it without root permissions
  5. Your logs will be stored in the /log directory on your DEVICE STORAGE, from where you can access them at any time.

 

Read More

  1. Where do Android Apps Store Data?
  2. What is /storage/emulated/0/? How to Access it?
  3. Which version of GApps to install for Lineage OS?

LEAVE A REPLY

Please enter your comment!
Please enter your name here