- 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
- Creating logs
- Using a batch file to render your work easier
- Crash log files
- First option: Using your iPhone or iPad
- Second Option: Using iTunes
- Third Option: Use iTools or another software
- Creating console logs
In case of crashes in a mobile app, devices 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, 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.
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
- Enable the developer options on your phone:
- Open the settings and navigate to System > About your phone.
- Tap the Build Number 7 times.
- Navigate back to Settings > System.
- Find the Developer options.
- Tap Take bug report and, if asked, pick the Interactive report.
- Monitor the report creation progress in your notifications.
- 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.
- Tailor the log output to the crash:
- Open the report text file on your computer (unzip it first if required).
- Find the SYSTEM LOG section of the report.
- If you know the time of the crash, use the timestamp to locate it.
- 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.
- 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.
The following steps need to be performed only once:
- Download Minimal ADB and Fastboot here or use any other source.
- Install the software or open the program folder if you chose the portable version.
- Prepare your device for using USB debugging.
- Connect your phone to your computer.
- On your phone, head to Settings > System > Developer options.
- Look for an option similar to USB Debugging, enable it, and confirm the warning message that may appear.
- Upon the first connection to your computer, confirm the security warning and tick Always allow from this computer to avoid future warnings.
- On your computer, open Minimal ADB and Fastboot either...
- … via the start menu (if you installed it) or…
- … 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.
- Connect your phone to your computer.
- Within Minimal ADB, enter the following command to check the successful connection: adb devices
- Your device should be listed among the connected devices.
- 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
- To start the actual logging, proceed as follows:
- Choose or create a folder on your computer, hold SHIFT and right-click the folder
- In the context menu, select Copy as path.
- 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"
- 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"
- Confirm by pressing Return.
- 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.
- Once you are done, press CTRL + C to stop the logging.
- 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:
- Download the portable version of Minimal ADB and Fastboot and navigate to the extracted folder.
- Create a new text file in this folder and open it in an editor like Windows Editor.
- 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
- 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.
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:
- On your phone or tablet, head to the Settings and tap Privacy.
- Proceed to Analytics and Analytics Data.
- Review the list of reports. The list is sorted alphabetically. Look for the name of the affected app and an appropriate timestamp.
- Once found, tap on the report.
- 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:
- Connect your iPhone or iPad to your computer.
- If not already present, install iTunes.
- Open iTunes and connect your phone or tablet via USB.
- Wait for the automatic synchronisation or trigger it manually.
- Find the reports folder on your computer:
- Mac OS X: ~/Library/Logs/CrashReporter/MobileDevice/<DEVICE_NAME>
- Windows: C:\Users\<USERNAME>\AppData\Roaming\Apple Computer\Logs\CrashReporter\MobileDevice\<DEVICE_NAME>
- Locate the appropriate .crash or .ips file based on the app name and timestamp.
- 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:
- Download, install and open iTools.
- Connect your phone via USB and confirm the driver installation if required.
- Click Toolbox in the top area of the app.
- Click Crash Reports.
- Select an item based on the app name and timestamp.
- 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:
- Download and install iTools.
- Connect your phone via USB and confirm the driver installation if required
- Click Toolbox in the top area of the app.
- Click Console Log.
- Reproduce your issue while capturing the log.
- Click Clear to reset the log history before beginning the reproduction if necessary.
- Reproduce the crash or faulty behavior on your phone.
- Click Save full Log.
- Provide a file name and confirm it.
- Attach the console log file to your bug report.