132

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?

1

12 Answers 12

227

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.

7
  • Good solution for Eclipse LogCat
    – Seraphim's
    Jul 30, 2013 at 13:10
  • 7
    My vision is immediately less blurry! :D
    – suomi35
    Nov 22, 2013 at 22:27
  • This is what I'm looking for quite a while
    – ar-g
    Oct 13, 2015 at 9:24
  • Worked like charm! Many thanks. Add word "dalvikvm" also in it. It's most annoying in logcat.
    – Atul
    Jun 4, 2016 at 15:42
  • 1
    Answer with logcat filtering is the proper one - stackoverflow.com/a/17468665/828237 Nov 24, 2017 at 9:37
80

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

5
  • this answer works in intellij 15's logcat > Edit Filter Configuration which brings up a modal titled, "Create New Logcat Filter" .
    – petey
    Feb 23, 2016 at 19:22
  • 1
    Thank you. Btw Lenovo phones have a lot of spam log messages
    – Seagull
    Jun 19, 2017 at 11:42
  • This only prevents logs with that tag from being rendered to the log though. Monitor still gets swamped with those calls in the background and it pushes the non "tag1|tag2|etc" calls out of the buffer. Is there a way around that? Jul 31, 2017 at 9:57
  • 1
    Answer with logcat filtering is the proper one - stackoverflow.com/a/17468665/828237 Nov 24, 2017 at 9:36
  • Or if one tag ^(?!tag1)
    – Vlad
    Oct 7, 2019 at 9:15
55

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.

5
  • 1
    @zest grep is a standard unix command. For windows you may try find /V "notshownmatchpattern". P.S. Apparently, the adb shell also has a grep. But it is not the same as the standard unix grep!
    – PCoder
    Mar 9, 2013 at 8:00
  • Yeah, I found it already, findstr - suck, possible to install powershell or grep (for windows:), the same as Linux as was wrote in readme, but not so much in practice) Mar 9, 2013 at 12:03
  • No adays, I would just adivce for windows to install git with git commandline tools. This would install all basic unix commandline tools for windowze. Aug 27, 2014 at 8:47
  • or install clink for common unix commandline tools on windowze Jun 10, 2015 at 8:29
  • @PCoder can you please write whole command for doing the same with windows CMD? Jun 22, 2016 at 10:41
43

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"
4
  • This is a good suggestion and works from the command line with no pipelines. You should update your answer imho to explain that the ":S" part is going to only emit Severe messages for the named components (which hardly ever happen). Again, good answer. People should vote up this one... Jul 12, 2013 at 16:30
  • 1
    @ChrisMarkle According to the docs the S is for 'silent'. I've updated the answer to explain this though, as you suggest.
    – Rich
    Jul 12, 2013 at 21:28
  • 2
    You can filter logcat output in the same way using the environment variable ANDROID_LOG_TAGS. I find it useful to have it always set to exclude some of the more spammy processes.
    – emidander
    Feb 6, 2014 at 21:13
  • 1
    This is a more universal solution, that has no dependencies on OS specific tools... Sep 25 at 2:50
39

^(?!.*(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

2
  • Some more : ^(?!(WifiMulticast|WifiHW|MtpService|PushClient|EGL_emulation|OpenGl*|InputReader|art|dalvik|Environment|DataRouter|AlarmManager|WindowManager|PhoneStatusBar|ActivityManager|ResourceType|PackageManager|gralloc*)) Mar 11, 2018 at 6:22
  • And more: (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))
    – Graeme
    Jan 30, 2020 at 16:20
17

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.

1
  • IMHO,This is more comprehensive way of filtering logs. Mar 15, 2017 at 13:31
8

With new LogcatV2 you should use this example:

-tag~: chatty|WifiHAL|HwBinder|Light|lsc_nvram|SensorService|thermal_repeater

and so on

6

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

5

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|[email protected]|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))
3

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.

2

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))
0

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.

1
  • Well I forgot to mention that I am using that on command prompt / inside a phone to read logs. And each time I tap a screen it shows InputReader / InputDispatcher messages which are just flooding the screen. Now I see also setting filters to "InputReader:S InputDispatcher:S" works :) Thanks for an answer!
    – Kostas
    Apr 1, 2011 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.