How to logcat

When you begin to heavily modify your device to fit your imagination of a perfect UI and functionality, i.e. by flashing Xposed and installing (or possibly developing) modules, you’ll get to hear the term “logcat” more and more. What is it and how do you get it? Read on and you’ll know.

Note that I’m a windows user so some things might be different on other operating systems.

What is the logcat?

The logcat is essentially the log on your device. Every application can output various information that get added to the logcat. Because of this the logcat can grow quite big, multiple thousand lines are common. The logcat can contain everything, from simple debugging output to complex crash information. Especially the crash info can help developers to fix problems and to improve their apps.

How do I read the logcat?

The logcat isn’t stored as a file on the device that you can just copy somewhere which makes things a bit more complicated. There are two ways to get a copy of the logcat: From your computer via ADB or through apps on the phone.

To get the logcat via ADB, you first need to enable USB debugging in the developer options. You also need the adb.exe which is a part of the Android SDK, but you can also get it as a standalone tool (Windows). After installation open a command prompt and navigate to the directory where you installed the ADB (cd path/to/install/dir). Then type adb devices to see a list of all attached devices. If there is none or it says “unauthorized” make sure to enable USB debugging on your phone. Next, execute adb logcat -v time > C:/path/where/to/save/it.txt. The logcat will be stored in the file you specified. Make sure the directories already exist. The command will run infinitely, to stop the output press ctrl + c. The -v time adds timestamps to the output and chages the formatting a bit to a way that I think is easier to read.

If you don’t have a computer at hand or can’t use the ADB for some reason, you can also grab your logcat on your phone. One drawback is that you’ll need root access to get the full logcat beginning from Andorid Jelly Bean (4.1). Another problem is that you can’t use apps to capture the logcat when you’re for example stuck in a bootloop or the SystemUI keeps crashing because of some Xposed modules. If you still want to use an app, I’d suggest MatLog. It’s based on CatLog with the difference that it’s still being maintained and it has Material design. In the app open the overflow menu, click “File” and then either “Save” or “Record”, depending on if you want to save the currently displayed logcat or want to constantly capture it in the background while you e.g. trigger crashes. The log will be saved in your main storage under catlog/saved_logs/<name>.txt. Important: If you are collecting the log for a bug report, don’t use a search filter, always save and submit the whole log. You may want to help the developer or filter out sensible information, but you never know which information the developer needs and in which way it gets logged, so always save the whole log without any filters. The dev knows best what he has to search for.

Now that you’ve captured your logcat you can upload and share it with the community and help developers improving their apps and making them accessible to everyone.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.