Via command line
Use Logcat
command-line tool on your computer
Logcat is a command-line tool that dumps a log of system messages, including stack traces when the device throws an error and messages that you have written from your app with the
Log
class.
in Logcat command-line tool | Android Studio | Android Developers
For that you will need to have Android Debug Bridge (adb) installed on your computer. There a couple of different ways to installed it: Using the standalone package (documented here) but you can also use the sdk-manager or if you already have installed the Android Studio.
- Use the standalone Android SDK Platform-Tools package, you can download it here. You can then extract it to a place where your computer recognizes it.
- Example, on Linux: Extract the package file to your
/home/<youruserNameHere>/.local/bin/platform-tools
or/home/<youruserNameHere>/bin/platform-tools
- Then make sure that folder is correctly added to your system
PATH
variable withexport
: by adding the following line to your.bashrc
export PATH=$PATH:/home/<youruserNameHere>/.local/bin/platform-tools
- Close and open your terminal or re-evaluate your
.bashrc
file withsource .bashrc
- Example, on Linux: Extract the package file to your
- You can now use
logcat
to view the messages in real timeadb logcat
- It will probably output the following:
* daemon not running; starting now at tcp:5037 * daemon started successfully - waiting for device -
- 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 now plug in your phone. For more info on the correct syntax see logcat#Syntax
With Android studio
The Android studio also allows you to view log messages right inside of the Android studio > logcat window.
With an application
There is also the possibility to export those log messages from within your Android phone without resorting to command-line nor Android studio: https://www.xda-developers.com/how-to-take-logs-android/