Crash Logs on Mobile Devices

How do you generate crash logs on mobile devices and retrieve them?

Markus avatar
Written by Markus
Updated over a week ago

"Where to find Crash logs on Mobile devices and how to get them? What is the easiest way?"

Motivation

In case of crashes in a mobile app, device logs are mandatory as a key component of your bug report. They can also be useful for app freezes. Only logged information can provide detailed insight into the circumstances of the issue.

In this article, you will find how can you retrieve log information for Android and iOS devices. Applying these techniques will allow you to record and attach meaningful log files to your reports.

Getting crash logs on Android devices

For Android devices there are two main approaches, one is to use Android Debug Bridge (ADB), and the second one is to use the integrated Bug Report Feature, inside the Developer tools in your phone. First, we will explain how to use ADB.

Crash logs Using ADB

For Windows in order to get crash logs via ADB, you will need to download SDK Platform Tools. You can download SDK Platform Tools here.

For macOS, you will need to install android-platform-tools using Homebrew. Installation instructions you will find further in this article.

Launching ADB on Windows and macOS

Windows

After you download SDK Platform Tools you will need to extract files (folder) from there. When you extract files (folder), you need to open extracted folder. After you open extracted folder, in the Address bar of File explorer click on free space, then when the File path will be shown, type cmd and press ENTER on your keyboard. This will launch cmd (Command Prompt) inside the folder, and in this way, ADB is basically started.

macOS

The first thing you need to do is to install Homebrew using Terminal and after that install android-platform-tools. To install Homebrew on your macOS visit the Homebrew website and copy the installation link under the Install Homebrew part. After you have copied the installation link, paste it into Terminal and press Enter on your keyboard. The Homebrew will start with installation. Follow the installation instructions to the end.

Note: In some cases, installation can take longer because installation of additional components but do not worry, everything is fine.

.After Homebrew is finished with the installation, you will need to install android-platform-tools. To install android-platfrom-tools, visit the android-platform-tools Homebrew Formulae website, and copy the Installation command. After you copied the installation command, paste it into Terminal and press Enter on your keyboard. The installation will start then. After the installation is finished, type in Terminal adb and press Enter. If you see adb commands, this means that the installation was successfully performed.

Note: After installing android-platform-tools, for every next usage you will only need to open Terminal and type commands for getting logs which are described further in this article.

Creating logs

In order to create logs, you will need to activate USB Debugging in Developer options in your phone and execute commands in previously opened cmd (Windows) or Terminal (macOS). If you have already activated Developer tools and USB Debugging, you can skip to Part 2.

Part 1: Activating USB Debugging on your Android device

1. Open the Settings app.
2. Search for the Build number (Usually it is located under Software information in the “About phone” part).
3. Tap on the Build number repeatedly until you see a message You are now a developer!

4. Now that you have activated the Developer options, find them in Settings and open them.
5. If developer options are not activated yet, please activate them by tapping on the toggle button.
6. Find the USB debugging option and enable it by tapping on the toggle button.

Part 2: Creating logs

1. In previously opened cmd (Windows) or Terminal (macOS) type adb start-server and press Enter on your keyboard. This will start the adb server.
2. Now connect your phone to your PC using a USB cable. If you did not use USB debugging before on your Android phone you should see a prompt Allow USB debugging? tap on OK. Also, you can check Always allow from this computer, and tap on OK to make sure that you are not asked over and over again when you try to get crash logs.
3. Now type in cmd or in Terminal, adb devices and press Enter, this will list devices connected to your PC, and make sure that your device is on the list.

Note: If you see after your device name text unauthorized, this probably means that you did not allow USB debugging. Make sure that next after your device name there is a text device.


4. To create a log for the reproducible issues, first clear the log history to remove unnecessary content by entering adb logcat -c and pressing Enter.
5. Now is the time to capture logs.
5a. If you want to create a log in the current folder (where platform tools are on Windows), you can type in cmd adb logcat -v time > crashlog.txt and press Enter on the keyboard. The logging process will start after pressing Enter.
5b. If you want to create a log in some other folder, you need to copy the file path of that folder (On Windows: Navigate to target folder --> Click on free space in the Address bar in File explorer --> Copy file path; On macOS: Select folder which you want --> Right click on it --> Click on Copy), after you have copied file path, in cmd or Terminal type adb logcat –v time > paste_file_path_here\log.txt and press Enter on keyboard (Command on Windows should look like this: adb logcat -v time > D:\testIO\Logs\crashlog.txt ; While on Mac it should look like this: adb logcat -v time > /Users/testIO/log/crashlog.txt). The logging process will start after pressing Enter.
6. Now that you have started logging, reproduce the bug or crash for which you want to create a log, and once you are done, in cmd or Terminal press CTRL + C, this will stop the logging process, and you should be able to see now your log file in the specified folder.

Video explanation: 5a. - Creating a log in the current folder where platform tools are

Video explanation: 5b. - Creating a log in some other Destination (Windows)

Video explanation: 5b. - Creating a log in some other Destination (Mac)

Bug Report Feature

Another way to get logs from your Android phone is by using the Android bug report feature directly in the developer options on your device, you can create bug reports at any time, which will include all log activity within a certain time frame depending on the size of your log buffer and the log activity on your device. This time frame can reach from a couple of minutes up to several hours or even days.

How to create a Bug report via the Developer options

1. Open the Settings app.
2. Search for the Build number (Usually it is located under “Software information” in the “About phone” part).
3. Tap on the Build number repeatedly until you see a message You are now a developer!

4. Now that you have activated the Developer options, find them in Settings and open them.
5. If developer options are not activated yet, please activate them by tapping on the toggle button.
6. Tap on Submit bug report or Take bug report (the name of this feature depends on the device), select Interactive report, and press the Report button.

7. Your report will be created now. You can track creating progress in your notification center. Once the bug report is ready, share the report by sending it to yourself via email or by uploading it to a target of your choice like Google Drive or Dropbox.
8. Open the report text file on your computer (unzip it first if required).

9. Find the SYSTEM LOG section of the report and attach it to your bug report.

Note: If your crash log is more than 25 MB, please extract the relevant part including some parts before and after the bug event and upload the crash log to your bug report.

Getting crash logs on iOS devices

Obtaining log information on iOS devices does not require much effort. Depending on the computer that you are using (Windows or Mac) we will show you in the following text how can you quickly extract logs and attach them to your bug report.

When a crash occurs on your iOS device, in most cases a .ips file will be automatically created and added to Analytics Data. This .ips file you will need to attach to your bug report when you are reporting a bug about the crash on an iOS device. You can find crash logs on your iOS device by following the next steps:

1. Open Settings on your iOS device.
2. Find and open Privacy & Security.
3. Open Analytics & Improvements.
4. Proceed to Analytics Data.

After you have opened Analytics Data, you will find all logs which are created on your iOS device. Now we have a part, how to quickly extract them? Depending on your computer (Windows or Mac), we recommend the following ways:

Windows

Using 3uTools. With 3uTools you will be able quickly to find and extract logs to your Windows PC, and the only thing that you need is a USB cable. To do so, proceed as follows:

1. Download 3uTools. You can download 3uTools here.
2. Install 3uTools and after installation is done, open 3uTools.
3. Connect your iOS device to your PC using a USB cable.
3a. If Trust This Computer? prompt is shown on your device, tap on Trust and enter your device Passcode if needed.
4. Make sure that your device is visible in 3uTools.
5. Click on Toolbox in the Navigation menu
6. Open Crash Analysis and then click on Files.

7. Find the corresponding log file and Export it to the destination which you want.

8. Attach the Exported log file to your bug report.

macOS

Extracting log files on macOS from an iOS device is even easier than on Windows. The fastest way to extract log files from your iOS device to your Mac is by using the AirDrop feature. To do so, proceed as follows:

1. In previously opened Analytics Data, open a corresponding log file.
2. Tap on the Share button in the upper right corner of the screen.
3. Tap on AirDrop.
4. Send the log to your Mac device.

5. Attach the log file to your bug report.

If you have trouble extracting logs from your iOS device, on your Windows or Mac computer with the previously given steps, there is also and one easy workaround. The only thing you need to do is to open the corresponding log file in Analytics Data, tap on the Share button, select the Mail app, and send the log to yourself. After that go to your mail on Windows or Mac computer, download the log and attach it to your bug report. Of course, if you have your own ways of extracting logs, you can use them also.

Note: Sometimes you will maybe experience a "crash" bug, but you will not be able to find a crash log, in this case, you will need to upload the Console log to your bug report. You can check how to create a Console log on your iOS device.

Did this answer your question?