How to filter out a tagname in Eclipse LogCat viewer
I have an Android application that "spams" the LogCat and I would like to remove its logcat entries in order to have an output more readable.
Is it possible to have a filter that remove the LogCat entries for a specific tag name? Or a search pattern that does the trick?
Solution 1:
Yes. Create a filter where the "By log tag" field is
^(?!.*(MYTAG)).*$
where MYTAG
is the tag you don't want to see. I am not a regexp expert (a "regexpert"? ;-) ) so there may be a simpler way to do that negation, but I just tried that and it works.
You can play around with the filter in the field just above the Log Cat message area, by entering filter strings there, like this:
tag:^(?!.*(DeskClock|dalvik|wpa)).*$
which will show all messages except tags "DeskClock", "dalvik", and "wpa".
Solution 2:
This might not seem directly relevant to the question but here is a regex which filters out most of the system generated logs when you put this in your tag filter as described by Rob.
^(?!(WifiMulticast|WifiHW|MtpService|PushClient|InputMethodManager|Provider|SurfaceTextureClient|ImageLoader|dalvikvm|OpenGLRenderer|skia|AbsListView|MediaPlayer|AudioManager|VelocityTracker|Drv|Jpeg|CdpDrv|IspDrv|TpipeDrv|iio|ImgScaler|IMG_MMU|ResMgrDrv|JpgDecComp|JpgDecPipe|mHalJpgDec|PipeMgrDrv|mHalJpgParser|jdwp|libEGL|Zygote|Trace|InputEventReceiver|SpannableStringBuilder|IInputConnectionWrapper|MotionRecognitionManager|Choreographer|v_galz|SensorManager|Sensors|GC|LockPatternUtils|SignalStrength|STATUSBAR-BatteryController|BatteryService|STATUSBAR-PhoneStatusBar|WifiP2pStateTracker|Watchdog|AlarmManager|BatteryStatsImpl|STATUSBAR-Clock))
I keep updating this list of tags as i encounter them testing on different devices. The list is not exhaustive and you are free to contribute to this answer. I am sure this will save an hour for many.
If there are other other logs you need filtered out, append them to this regex using a ' | ' character.
Solution 3:
Depends on which way you view your logcat.
If you are using the GUI logcat interface it's best to create a filter for the tags you want to see. These get dropped into a seperate category. Though the ui changed a bit you can use this old answer from me. Should be clear how this is used (make sure that the "display saved filters tab" button is pressed though, otherwise you won't see the "Add filter" button. You can find that on the top-right of the log). I'm not aware of any option that lets you filter out certain tags from the whole logstream.
If you are using the command line you can mute certain tags. Example:
adb logcat AndroidRuntime:S *:V
shows everything (*:V
) up to the verbose log level, except the tag AndroidRuntime, which will be limited to the "silence" loglevel, which means it will print nothing.
To display a single tag you can use
adb logcat *:S MyAppTag:V OtherTag:V
Same way, everything gets silenced except MyAppTag and OtherTag. See Filtering Log Output for more details.
Solution 4:
I couldn't get chosen solution to work properly in Android Studio (the IDE that will come with future versions of android SDK). However the following regex solved my problem:
^(?!dalvikvm)