Contents

Motivation

Android Logging

  • Bug report feature
  • How to create Android bug reports via the developer options
  • Create logs with the Android Debug Bridge (ADB)
  • How to create Android logs via ADB
  • Preparations
  • Creating logs
  • Using a batch file to render your work easier
  • Troubleshooting

iOS Logging & Crash Dumps

  • Crash log files
  • First option: Using your iPhone or iPad
  • Second Option: Using iTunes
  • Third Option: Use iTools or another software
  • Creating console logs

Related articles and links


Motivation

In case of crashes, freezes, or any other critical functional issue in a mobile app, devices logs are mandatory as a key component of your bug report. Only logged information can provide detailed insight into the circumstances of the issue.

In this article, we will demonstrate common solutions to retrieving log information for both iOS and Android devices. Applying these techniques will allow you to record and attach meaningful log files to your reports.


Android Logging

Depending on the situation and the available devices, there are two main approaches to retrieving Android device logs:


Bug report feature

With the Android bug report feature directly in the developer settings 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 logg activity on your device. This time frame can reach from a couple of minutes up to several hours or even days.


How to create Android bug reports via the developer options

  1. Enable the developer options on your phone:
  2. Open the settings and navigate to System > About your phone.
  3. Tap the Build Number 7 times.
  4. Navigate back to Settings > System.
  5. Find the Developer options.
  6. Tap Take bug report and, if asked, pick the Interactive report.
  7. Monitor the report creation progress in your notifications.
  8. Once ready, share the report by sending yourself an email or by uploading it to a target of your choice like Google Drive or Dropbox.
  9. Tailor the log output to the crash:
  10. Open the report text file on your computer (unzip it first if required).
  11. Find the SYSTEM LOG section of the report.
  12. If you know the time of the crash, use the timestamp to locate it.
  13. If you do not know the time, you can search for keywords like exception, crash or has died, which are related to the app under test.
  14. Extract the relevant part including some time before and after the bug event.

Please have a look at the following example of a crash event, which includes the stack trace of the error event and allows a developer to locate the bug:


Create logs with the Android Debug Bridge (ADB)

By utilizing the Android Debug Bridge, you are able to create log files that cover a certain time frame. Those files are smaller and focus on a particular issue that should ideally be easily reproducible. These logs do not require you to manually look for crash events and are the preferred method to create meaningful logs for reproducible issues.


How to create Android logs via ADB

Numerous tools are available for creating an ADB connection to your phone. A very small and versatile one is Minimal ADB and Fastboot.


Preparations

The following steps need to be performed only once:

  1. Download Minimal ADB and Fastboot here or use any other source.
  2. Install the software or open the program folder if you chose the portable version.
  3. Prepare your device for using USB debugging.
  4. Connect your phone to your computer.
  5. On your phone, head to Settings > System > Developer options.
  6. Look for an option similar to USB Debugging, enable it, and confirm the warning message that may appear.
  7. Upon the first connection to your computer, confirm the security warning and tick Always allow from this computer to avoid future warnings.


Creating logs

  1. On your computer, open Minimal ADB and Fastboot either...
  2. … via the start menu (if you installed it) or… 
  3. … head to the folder of the portable version, hold the SHIFT key, right-click an empty spot of the folder, and select Open command prompt here – respectively Open PowerShell here on Windows 10 machines.
  4. Connect your phone to your computer.
  5. Within Minimal ADB, enter the following command to check the successful connection: adb devices
  6. Your device should be listed among the connected devices.
  7. If you want to create a log for a reproducible issue, first clear the log history to remove unnecessary content by entering: adb logcat -c
  8. To start the actual logging, proceed as follows:
  9. Choose or create a folder on your computer, hold SHIFT and right-click the folder
  10. In the context menu, select Copy as path.
  11. Within Minimal ADB, enter: adb logcat > and paste your path by right-clicking the log window whereafter it may look like this: adb logcat > "D:\Logs"
  12. Now, add a file name to the path that will then look like this (please be sure to use the TXT file extension): adb logcat > "D:\Logs\log.txt"
  13. Confirm by pressing Return.
  14. Reproduce the bug or crash for which you want to create the log. Although nothing happens in the log window, Minimal ADB is recording the logg activity in the background.
  15. Once you are done, press CTRL + C to stop the logging.
  16. You will now find your log file in the specified folder.


Using a batch file to render your work easier

To avoid having to enter all commands manually each time, you can create a batch file to automate these tasks. For that purpose, proceed as follows:

  1. Download the portable version of Minimal ADB and Fastboot and navigate to the extracted folder.
  2. Create a new text file in this folder and open it in an editor like Windows Editor.
  3. Add the following content: @ECHO OFF; echo Clearing the log history…; adb logcat -c; echo Starting live logging. Press CTRL + C to stop.; adb logcat > device_log.txt
  4. Save the file as log.bat and make sure that .bat is the actual file extension.

Whenever you execute this file, a new log file will be created in the current folder. The old ones will be overwritten.


Troubleshooting

If Minimal ADB does not recognize your phone, you can use an alternative driver like the Universal ADB Driver, which can be found here. Disconnect your phone, install the driver, and connect your phone again. Afterwards, try to create a log again.

Also, make sure that your phone is not set to Charge only if it is connected to your computer. Select File transfer or Media transfer instead.


iOS Logging & Crash Dumps

Obtaining log information on iOS devices does not require much effort and usually no access to a computer. Different types of log information can be obtained and we want to cover several approaches of retrieving them.


Crash log files

The most common type of log data is the crash report file that is automatically created in the background once a crash occurs on your iOS device. Gathering this file and attaching it to your bug report will be sufficient for the majority of crashes. Several approaches are available to obtain these files and we would like to cover three of them.


First option: Using your iPhone or iPad

You can access a history of crash reports directly on your phone and without involving a computer. For this purpose, proceed as follows:

  1. On your phone or tablet, head to the Settings and tap Privacy.
  2. Proceed to Analytics and Analytics Data.
  3. Review the list of reports. The list is sorted alphabetically. Look for the name of the affected app and an appropriate timestamp.
  4. Once found, tap on the report.
  5. Share its content to an app of your choice and attach it to your bug report.


Second Option: Using iTunes

You can also use iTunes to access all crash reports on your phone – just a synchronisation is required:

  1. Connect your iPhone or iPad to your computer.
  2. If not already present, install iTunes.
  3. Open iTunes and connect your phone or tablet via USB.
  4. Wait for the automatic synchronisation or trigger it manually.
  5. Find the reports folder on your computer:
  6. Mac OS X: ~/Library/Logs/CrashReporter/MobileDevice/<DEVICE_NAME>
  7. Windows: C:\Users\<USERNAME>\AppData\Roaming\Apple Computer\Logs\CrashReporter\MobileDevice\<DEVICE_NAME>
  8. Locate the appropriate .crash or .ips file based on the app name and timestamp.
  9. Attach it to your bug report.


Third Option: Use iTools or another software

Alternatively, you can use software like iTools to access the crash reports on your phone. To do so, proceed as follows:

  1. Download, install and open iTools.
  2. Connect your phone via USB and confirm the driver installation if required.
  3. Click Toolbox in the top area of the app.
  4. Click Crash Reports.
  5. Select an item based on the app name and timestamp.
  6. Click Export to save the file and attach it to your bug report.


Creating console logs

Sometimes, you might not be able to find and provide a crash log file as the app might not have actually crashed but showed a different critical behavior. Alternatively, you may be asked to provide further information regarding the circumstances of an issue where console logs can be used to provide further insight.

There are several approaches to gathering console logs but we want to cover an easy approach using the software iTools, which is available as a free trial version:

  1. Download and install iTools.
  2. Connect your phone via USB and confirm the driver installation if required
  3. Click Toolbox in the top area of the app.
  4. Click Console Log.
  5. Reproduce your issue while capturing the log.
  6. Click Clear to reset the log history before beginning the reproduction if necessary.
  7. Reproduce the crash or faulty behavior on your phone.
  8. Click Save full Log.
  9. Provide a file name and confirm it.
  10. Attach the console log file to your bug report.


Related articles and links: 

Did this answer your question?