How to exclude certain messages by TAG name using Android adb logcat?

AndroidFilterAdbLogcat

Android Problem Overview


Logcat allows filtering logs but it works like that: You define filters and logcat only displays messages which matches filters. But is there a way to display all logs EXCEPT some TAGs defined by filters?

Android Solutions


Solution 1 - Android

You can do this from within DDMS Monitor (and also Eclipse or Android Studio) with the regular expression input box and negative look-ahead assertions, for example I am excluding a lot of noise from my log with the following:

tag:^(?!(WifiMulticast|WifiHW|MtpService|PushClient))

(The "tag:" isn't part of the regular expression, but tells LogCat to only apply the regex to the Tag field. If you use this trick in a saved filter then put just the regular expression in the "Tag" input box, and omit the "tag:" prefix)

In Android Studio's logcat monitor pane, you can set up a saved filter for this by opening the dropdown in the upper right (it may have "Show only selected application" selected) and selecting Edit Filter Configuration. Create a new logcat filter and put ^(?!(WifiMulticast ...etc. )) in the Log Tag box, with the Regex checkbox checked.

Solution 2 - Android

If you want to exclude or filter certain messages by tag name in Android studio, goto the LogCat window=>Edit Filter configuration, and enter the following under "by Log Tag(regex): "

^(?!(tag1|tag2|tag3|tag4))

Note that there are no spaces, this is important

Solution 3 - Android

If you are using adb logcat you could pipe it through grep and use it's inverted matching: From the grep manpage: > v, --invert-match > Invert the sense of matching, to select non-matching lines.

For example:

$adb logcat | grep --invert-match 'notshownmatchpattern' 

You can extend this by using regular expressions.

Here is an example of such an expression:

"/^(?:emails|tags|addresses)"

This one would check for either of the given to occur, grep would then not list them.

Solution 4 - Android

From the shell, you can use a command like:

adb logcat AlarmManagerService:S PowerManagerService:S *:V

which will include all logs apart from those with the AlarmManagerService and PowerManagerService tags.

(The :S stands for "silent", which means nothing will be printed for those tags; the :V stands for "verbose" which means everything will be printed for all other tags. The Android documentation for logcat has more details of other options you can use in the filters.)

You can also use the ANDROID_LOG_TAGS environment variable to set up default filters, e.g. (in bash):

export ANDROID_LOG_TAGS="AlarmManagerService:S PowerManagerService:S *:V"

Solution 5 - Android

^(?!.*(WindowManager|dalvik|Environment|DataRouter|AlarmManager)).*$

This will exclude texts having contents WindowManager,dalvik,...

tag:^(?!.*(WindowManager|dalvik|Environment|DataRouter|AlarmManager)).*$

This will exclude tags WindowManager,dalvik,... from logcat

Solution 6 - Android

Combine both positive and negative lookahead for more powerful filtering.

Example:

(?=(AndroidRuntime|Main|RandomTag))(?!(Audio))

Tags in the first nested parentheses are included.

Tags in second are excluded.

Solution 7 - Android

There is also the option to make your own filter in Android Studios logcat GUI. E.g. I was very annoyed by OpenGLRenderer and ViewRoot messages in logcat.

In the logcat click on Edit Filter Configuration and create a new filter. In the Log Tag Input you can type in something like ^(?!.*(OpenGLRenderer|ViewRoot)) and add several other Tags that are annoying you.

Filter for logcat

Solution 8 - Android

Here's a list of filters that I've been using to ignore Samsung system logs. would work with other devices too.

> Logcat -> Edit Filter Configuration -> Log Tag

^(?!(PowerUI|PowerPlanningReceiver|BatteryService|SamsungPhoneWindowManager|MotionRecognitionService|AudioService|APM_AudioPolicyManager|SensorService|StorageManager|SignalClusterView|BatteryService|TelephonyManager|UsbDeviceManager|KeyguardUpdateMonitor|BatteryController|ActivityManager|LauncherAppsService|AppsModel|DataLoader|PackageManager|LauncherApps|ContactsImsCommon|ImsUtil|ImsSettingsProvider|DeviceConfigManager|WifiService|BackupManagerService|PersonaManagerService|DefaultDialerManager|ResourceType|NetworkUIGlobals|NetworkProxy|FileWriteThread|ReflectUtil|PhoneApp|SamsungAlarmManager|display|DeviceStorageMonitorService|wrapperGPS|io_stats|GnssLocationProvider|KeyguardServiceBoxContainer|ConnectivityService|SSRM|TLC_TIMA_PKM_initialize|mc_tlc_communication|TeeDriverClient|TLC_TIMA_PKM_measure_kernel|AutomaticBrightnessController|BatteryUtils|WifiConnectivityManager|Launcher|IconView|ApplicationPackageManager|LiveIconLoader|WifiScanningService|WifiHAL|WifiScanController|ApplicationPolicy|SELinux|TimaKeyStoreProvider|ActivityThread|zygote|GservicesProvider|GoogleHttpClient|cr_ChildProcessConnect|WificondControl|Netd|Tethering|ContactsImsCommon|ImsConstants|tnet-jni|BatteryStatsService|SignalClusterView|LiveIconManager|BitmapCacheContainer|com.samsung.android.app.powerplanning.utils.BatteryUtils|ReflectField|cr_ChildConnAllocator|TinLoadingFailTracker|WifiPermissionsUtil|EventHandler_FLP|android.hardware.wifi@1.0-service|BluetoothAdapter|bt_btm|WifiPermissionsUtil|GeofencerStateMachine|Places|GCoreUlr|BeaconBle|Sensors|SLocation|ContactsProvider_EventLog|WificondScannerImpl|AlarmManager|AlarmManagerEXT|MultiDex|NetworkSecurityConfig|DnsProxyListener|dalvik-internals|mobileconfig|SsacManager|ImsPhoneStateManager|VolteServiceModule|PdnController|PowerManagerService|GameManagerService|NoSync|SensorManager|DisplayPowerController|NetworkController|SamsungAnalytics111040|tlcFidoAuthnr|InputReader|FlashlightController|KeyguardWallpaperController|OpenGLRenderer|EasyMuteController|Vibrator|VibratorService|PowerManagerUtil|LightsService|WindowManager|InputDispatcher|InputReader|CustomFrequencyManagerService|SystemUIAnalytics|SamsungAnalytics|swipe|PanelView|BadgeCache|MARsPolicyManager|MARsDBManager|KeyguardClockPage|ScanManager|RegiMgrBase|secImsManager|GeolocationController|MultiSimUtils|CarrierText|Mms|NetworkNotificationUI2|CommandListener|ReschedulableTimer|RCS-ContactsImsCommon|Settings|DmConfigModule|NotificationMgr2|PhoneMultiSimUtils|PhoneProxy|VideoCapabilities|AudioCapabilities|SAIV_FACE|FaceController|FaceService|SamsungAnimationCreator|ImageWallpaper|Finsky|VirtualScreen|PagedView|DragLayer|HomeContainer|ImsServiceStub|DmConfigHelper|TZ))

Solution 9 - Android

An easy way to do this is by simply filtering in only the tags you want to see.

adb logcat -s "Tag1" -s "Tag2" -s "Tag3"

Will bring up only those tags.

Solution 10 - Android

This is The Most common Annoying Tags i gathered

^(?!.*(OpenGLRenderer|ViewRoot|ForceDarkHelper|Looper|PlayCore|AudioTrack|SurfaceUtils|cr_ChildProcessConn|FA|ActivityThread|DynamiteModule|Perf|DynamitePackage|EgretLoader|cr_LibraryLoader|BpBinder|chatty|FeatureParser|MediaCodec|ExtendedACodec|MapperHal|OMXClient|VideoCapabilities|Gralloc3|MetadataUtil|AdrenoGLES|chromium|DpmTcmClient|WebViewFactory|cr_CachingUmaRecorder|AdrenoUtils|cr_media|AudioManager|cr_SpareChildConn|Chrome_InProcGp|Choreographer|AdInternalSettings|Keep-Alive|Vary|pool-15-thread-|WifiMulticast|WifiHW|MtpService|PushClient|EGL_emulation|OpenGl*|InputReader|art|dalvik|Environment|DataRouter|AlarmManager|WindowManager|PhoneStatusBar|ActivityManager|ResourceType|PackageManager|gralloc|Gnss|NetRec|ResolverController|GAv4|AsyncOperation|AppOps|WificondControl|aofp|wifi|netmgr|ctxmgr|BestClock|FirebaseInstanceId|android.os.Debug|memtrack|netd|system_server|StrictMode|bluetooth|NetworkMonitor|FA|BroadcastQueue|ConnextivityService|WakeLock|HttpClientWrapper|RAWR|Tenor|BgTask|WifiService|BluetoothAdapter|UpdateStatsService|AppIdleHistory|Connectivity|VelvetNetworkClient|WorkerManager|EGL_emulation|chatty|gralloc|InputReader|ActivityThread|ActivityTaskManager|UsageStatsService|ocess.gservice|DropBoxManagerService|EventLogChimeraService|PContextMetricsRunner))

Solution 11 - Android

Within the Eclipse Logcat view there's not such an option. However you can make use of the log level to exclude any message whose log level is too low. E. g. setting it to I(nfo) doesn't display D(ebug) and (V)erbose messages.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionKostasView Question on Stackoverflow
Solution 1 - AndroidZoFreXView Answer on Stackoverflow
Solution 2 - AndroidPhileo99View Answer on Stackoverflow
Solution 3 - Androidchris polzerView Answer on Stackoverflow
Solution 4 - AndroidRichView Answer on Stackoverflow
Solution 5 - AndroidRinoView Answer on Stackoverflow
Solution 6 - AndroidBakerView Answer on Stackoverflow
Solution 7 - AndroidMarcel HofgesangView Answer on Stackoverflow
Solution 8 - AndroidRamesh JayaView Answer on Stackoverflow
Solution 9 - AndroidWintermuteView Answer on Stackoverflow
Solution 10 - AndroidMohammad SommakiaView Answer on Stackoverflow
Solution 11 - AndroidLars BlumbergView Answer on Stackoverflow