In my logcat there is too much output, so I'd like to filter it using some keywords, basically displaying only the output containing the keyword(s). Is there a way to do that in Android Studio through the UI?
There are two ways to do this, both are in the Android tab at the bottom of the IDE (where the logcat output is displayed).
First, you can simply type something into the search box at the top and it should filter only messages containing the text you type.
Second, you can do advanced filtering by clicking on the dropdown at the top right, which should be displaying No Filters by default, and choose Edit Filter Configuration
and specifying what to filter on. Using this method you also save the filters and can re-use them by selecting them in the dropdown.
Screenshot:
There are two ways to do this, both are in the Android tab at the bottom of the IDE (where the logcat output is displayed).
First, you can simply type something into the search box at the top and it should filter only messages containing the text you type.
Second, you can do advanced filtering by clicking on the dropdown at the top right, which should be displaying No Filters by default, and choose Edit Filter Configuration
and specifying what to filter on. Using this method you also save the filters and can re-use them by selecting them in the dropdown.
Screenshot:
As @free3dom said you can select the process from which you want to receive logcats. Here is the screenshot.
Log cat has a new option (on by default) which creates an application filter automatically such that only the launched application's output is shown
–
Ecto I MADE A VIDEO TUTORIAL TO SHOW YOU HOW= https://youtu.be/xw2qE5ko_9I
Give your log a name. I called mine "wawa".
In Android Studio, go to Android-> Edit Filter Configurations
Then type in the name you gave the logs. In my case, it's called "wawa". Here are some examples of the types of filters you can do. You can filter by System.out, System.err, Logs, or package names:
First declare your TAG names in your code e.g.
private static final String TAG = "MainTagName";
Then add log statements where you want to output something
Log.d(TAG, "Activity created");
As per free3dom in the second post, on the logcat tab click on the Filters dropdown and then Edit Filter Configuration.
In this example we are using by Log Tag (regex) option to display log messages for any of the three matching tag names using the pipe | separator (without spaces):
MainTagName|SomeTagName|SomeOtherTagName
With AndroidStudio Dolphin a new logcat view mode was introduced providing a more structured view of the logcat output. It also introduced the new filtering options package:, tag: and level:. You can also search for the text in the whole entry by not preceding an option.
Quoting from Googles News post where the new logcat was introduced (https://androidstudio.googleblog.com/2022/03/android-studio-dolphin-canary-6-now.html) [Update] Proper Documentation is now available here https://developer.android.com/studio/debug/logcat
Specific values:
- package:<my-package-ID>
- tag:<my-tag>
- level:[VERBOSE | INFO | ASSERT | DEBUG | WARN | ERROR]
Exclude a specific value by preceding the key with -:
- -tag:<exclude-this-tag>
Use the regular expressions with a given key by placing a ~ after the key:
- tag~:<regular-expression-tag>
Combine with the exclude tag:
- -tag~:<exclude-this-regex-tag>
You can also see a history of queries by clicking the filter icon in the query field and selecting them from the drop down. To favorite a query so that it stays at the top of the list across all your studio projects, click the star icon at the end of the query field.
package:mine
matches all PIDs for the local app project.
see this https://medium.com/zinuzoid/if-you-developing-android-application-1bdff0a96205
just create LogCat filter a insert below String to "LogTag" which will then ignore system lines
^(?!.*(BtGatt|dalvik|Environment|DataRouter|FA|art|Wifi|ServiceManager|Atfwd|tnet|MDnsDS|Download|Bluetooth|slim|QSEECOMAPI|WVCdm|QC-time|sensors|nanohub|Drm|Babel|Dropbox|gsamlab|Cryptd|Vold|QC_|Conscrypt|Dns|sound|NetWork|OpenGL|TLog|GMPM|Microphone|Process|Dynamite|cr_|VideoCapabilities|libEGL))
I had trouble turning on the filters in Logcat. To see the filters in Android Studio 3.2, you have to toggle 'Floating Mode' on and off again to make the filters reappear.
One alternative that works for me is to select the Show only selected application
option in the filter menu:
I don't know if the images in the other answer are old or if I was missing something, but here is an updated image.
Click the Android Monitor tab at the bottom and make sure the logcat tab is selected. Then type in whatever you want to filter your output. I filtered mine with my tag name TAG
.
Just to add my own mistake:
make sure that when you are using the Emulator and a real device, to switch to the device you are debugging in the dropdown on the left above the logcat tab.
© 2022 - 2024 — McMap. All rights reserved.
Log cat has a new option (on by default) which creates an application filter automatically such that only the launched application's output is shown
– Ecto