Android Studio’s new Logcat — learning to use this powerful tool.

Nikolay Miroshnychenko
3 min readDec 21, 2022

--

Photo by Madara Parma on Unsplash

So, I guess you couldn’t help but notice the new logcat interface for the Android Studio Dolphin version. It looks something like this:

The problem with this new logcat, however, is that it’s not really obvious how you can filter the info. You can get all of the info related to the new logcat here.

Getting your app’s logs

The first thing you can do to make your logcat give you some meaningful info is to filter out only the logs that are related to your app. We can do it by applying package:mine to the filter field like so:

Now you should be able to see only the logs that are related to your app

Filtering by log level

Now let’s get only DEBUG level logs. This is also pretty simple. All we need to do is specify the level field followed by a colon and our desired log level after that. So if we wanted to get a DEBUG log level we could do it like so:

level: DEBUG

And we can also apply other log levels using these keywords:

[VERBOSE | INFO | ASSERT | DEBUG | WARN | ERROR]

Filtering by tag

Adding filtering by tag is also pretty straightforward. You can do it like so:

tag: ShopScreenTag

Another cool thing is that you can apply multiple tags at the same time which can help in tracking logs throughout a whole flow, for example.

tag: ShopScreenTag tag: HomeScreenTag

You can also use a regular expression as well in your tag. If we wanted to get logs from all of our services we can do it this way

tag~: \w+Service

This would filter out all log tags that end with “Service”.

Putting it all together

With all of these options applied we can pin down pretty specific logs for our use case. We can apply all of our options together like so

package: mine level: VERBOSE tag~: \w+Fragment

Which would filter logs by VERBOSE level for all fragments in our package.

Compact view

Another new feature is that you can view your logs in a “Compact” way now. You can do so by pressing this button on the left hand side of your logcat:

And then you need to choose Compact View. In my opinion it looks much neater that way.

Conclusion

When I first saw the new Logcat I didn’t really like it aside from the better visuals. To me, it was not obvious how I can filter my logs the way that would be easy to see and use.

Now that I have figured that out I understand that it’s much more powerful than the previous logcat and more flexible as well. I hope this article helped you figure out how to improve your logging with the new logcat as well :)

Thanks for reading. If you found this post valuable, please recommend it (the little handclap) so it can reach others.

--

--

Nikolay Miroshnychenko
Nikolay Miroshnychenko

Written by Nikolay Miroshnychenko

Android engineer. Learning daily and sharing my knowledge in the process. Into mobile, computer science, and the brain.

No responses yet