Friday, April 19

Android LogCat Filter for multiple tags in Eclipse –

Question or issue in pp Development:

Clicked on create filter could not figure out from docs how to create a filter for say two or more tags. If I have two tags com.test.TestClassA and com.test.TestClassB how do I create a filter that shows log for both of these classes? I saw how you can start ADB for only certain tags, but how can this be done in eclipse? Please provide details thanks. What exactly do I need to enter on the tag line when creating a new filter in eclipse?

How to solve this issue?

Solution no. 1:

As pointed by Brain Reinhold you can combine tag filters with vertical bar | (which obviously means logical “OR”). You can also use that (as well as other Regex) syntax in the logcat search box (by preceding tags with tag: prefix):

tag:com.test.TestClassA|com.test.TestClassB

More complex filtering is also possible. For example here is the search filter that displays messages from either android.process.media or com.android.camera apps, which have at least one digit (d) in the message text and are tagged with either dalvikvm or AndroidRuntime tags:

app:android.process.media|com.android.camera tag:dalvikvm|AndroidRuntime text:d

Screenshot

One short and useful filter is tag:^(?!dalvikvm) which removes all those noisy Dalvik logs.

It’s also worth mentioning that you can quickly disable any part of the filter by placing vertical bar at the end of the part you wish to disable (e.g. placing | right after app:android.process.media|com.android.camera in the example above effectively disables filtering by application name while still preserving filtering by tags and text).

Solution no. 2:

In the latest version of the SDK for Eclipse which now shows two versions for logcat (one deprecated); in the undeprecated version one can combine filters using OR bars: |.

For example when clicking on the + and bringing up a dialog to create a new filter, give your filter a name and then in one of the fields (for example TAG) enter com.lampreynetworks|Bluetooth and you will see output for all tags containing com.lampreynetworks and Bluetooth. The ‘*’ is implicit here as if any part of the TAG contains any of that text it will be displayed. Also note, there must be no spaces between the OR bars!

I have not tried combining the ‘by TAG’ and ‘by (some other option)’ but somehow I have a feeling that will not work.

Solution no. 3:

On Feb 12, 2:58 am, AndroidDevTime wrote:

If I have two tags
com.test.TestClassA and com.test.TestClassB how do I create a filter
that shows log for both of these classes?

The “Log tag” field accepts Java regular expressions, so do this:

^com.test.TestClassA$|^com.test.TestClassB$

which matches exactly those tags you specified. You could be more economical/efficient/whatever with the regular expression, depending on how much you want to muck around with that.

Solution no. 4:

It is not possible right now.
@see http://groups.google.com/group/android-developers/browse_thread/thread/17356ef7bdf1550f?pli=1
I also wish it were…

Solution no. 5:

I just do it from the command line. Having a different terminal for each adb filter. Then if you line them up side by side you can get a good idea of what is happening.

Solution no. 6:

The only way I have seen is Create a Filter using PID so that evey log message of your application will be displayed in that Filter. I wonder if this is possible through tag names in the current version of the ADT for eclipse.

Solution no. 7:

Use proclogcat: http://devtcg.blogspot.com/2010/04/logcat-improved.html

It lets you filter by your package name instead.

Good Luck!

Related Tags:

logcat regex,textnow logcat,adb logcat | grep

Leave a Reply

Your email address will not be published. Required fields are marked *