Hide Unnecessary Logs from Logcat

Shain Singh
MindOrks
Published in
2 min readJan 6, 2019

Sometimes we want to debug the application using application Logcat, but the application logs contain lots of unnecessary logs like zygote, Firebase logs, and other unnecessary stuff which is not important for that moment.

Proper logs information make application log easy to read, debug and fix the issue eatliest

Let’s improve application Logcat readability by doing simple stuff.

  1. Improve logs readability in Android Studio Logcat
  2. Fetch the filtered logs and other details within an app

1. In Android Studio

Instead of every time selecting the package from the package list, we can create a filter and add the package name of the debugging app.

To remove the unnecessary logs from the Logcat by creating a filter list based on the tag. We can create regex like if you want to remove Firebase log from Logcat.

Firebase logs displayed in Logcat with tag FA, so create a regex to hide tag FA ^(?!.*(FA)).*$ and put that in Log Tag in Logcat Filter dialog in Android Studio.

Create Logcat Filter

2. Within Application Logs

Sometimes we want to show the logs within the application for debug purpose. Like application has a connectivity issue with the server in some devices. In that case, you can ask for logs or user can submit the log to you.

We can get logs within an application from below code. The code gives the app, device, and logs information.

We are grabbing the logs using Runime.getRuntime().exec(“logcat -d *:I FA:S Glide:S”)

Here we are creating a filter expression for displays all log messages with priority level “information” and higher on all tags. FA:S Glide:S filter the Firebase and Glide logs.

:S Silent (highest priority, on which nothing is ever printed)

For more details about Logcat command line tools like Logcat formatting or more command line syntax go to below link.

Hope this above information makes your application logs more precise and readable.

Clap, share if you like it and let’s connect on LinkedIn, Twitter

--

--

Shain Singh
MindOrks

Senior Software Engineer-Android | Flutter | Kotlin