Logs – how to filter them in Android Studio

I’ve stumbled across a lot of logs noise in Android Studio throughout the time and it can be a pain when you need to debug a crash or just read some important logs of your app when your device/emulator prints lots of logs. Those logs are helpful for some cases but might not be for yours.

There is a simple way to filter Android Studio logs by ignoring the ones you don’t need and that can be easily done and you can see how in the following lines.

Steps to filter logs in Android Studio

  1. Open your project with Android Studio
  2. Open the Logcat window/tab
  3. Go to “Show only selected application” filter drop down (should be on the right of the logcat window)
  4. Select “Edit Filter Configuration” item from the drop down
  5. In the “Create New Logcat Filter” window you can add a new filter depending on your needs in the respective sections (“Log Tag”, “Log Message” or “Package Name”)

Below you can see the steps in images (because for most of us those are 1000 times better than words 🙂 ).

How to add logs filters steps in Android Studio - image
How to add logs filters steps in Android Studio
Create a new Logcat filter Dialog in Android Studio

Based on what you need you can add Regex for tags, messages or package names (that compose a log output in logcat). Make sure you also select the appropriate/desired “Log level” and then press ok and select your newly created log filter. The output should be much cleaner now.

Below you can see a simple sample of regex for 3 tags and that one will filter out any of those encountered tags from the logcat output in Android Studio that starts with any of the enumerated tags. The ‘!’ mark does the trick(makes those tags disappear from your logs list) but you can play with it and see what better fits your needs. Also, you can see that I’ve added 3 example tags separated by “|”, you can leave as many as you need or leave just one.

^(?!(oneTag|anotherTag|theLastOne))

I adapted the Regex from this stackoverflow post. You can exercise more with Regex here.

If there are other ways to do this please write them in the article comments section so others can see them and better filter their logs in Android Studio.

keyboard_arrow_up