The Android Studio Dolphin 🐬 update brought an exciting revamp to the logcat feature, but with great power comes the challenge of mastering log filtering. Many developers have found themselves swimming in a sea of logs. Fear not! Dive into this blog for a handy cheat sheet that'll have you effortlessly surfacing the logs you need with a grin 😃.
Filter Fields
package:mine - Displays the logs of package names of currently open project.
package:com.example - Displays the logs of package name specified i.e.
com.example
in given example.
- is:crash - Displays the logs related to crashes.
- is:stacktrace - Displays the logs of full stack trace.
- is:firebase - Displays the logs related to firebase.
- tag:AppName - Displays the logs matching log tag AppName.
-
message:AppName - Displays the logs matching log tag AppName. If the sentence has spaces, separate the words with the slash
\
sign. - level:DEBUG - Displays the logs matching log level DEBUG. Other valid values are: VERBOSE, WARNING, INFO, ERROR and FATAL.
-
age:1m - Displays the logs with a timestamp of the last 1 minute. There are following supported time units:
- s - seconds
- m - minutes
- h - hours
- d - days
Match Operators
-
Regex - Append ~ after any field. E.g.
tag~:Activity
displays logs which contain log tag "Activity". -
Exact match - Append = after any field. E.g.
tag=:Activity
displays logs which exactly has log tag "Activity". -
Negation - It works like NOT operator. Prepend
-
to the field name. E.g.-tag:Activity
displays logs which don't have the log tag "Activity". -
Logical Operators - AND(&) and OR(|) signs are supported in logs. E.g.
package:mine & (tag:AppName | message:This\is\sample)
. -
Space - Space is an implicit AND logical operator. E.g.
package:mine tag:AppName message:Sample
will evaluated aspackage:mine & tag:AppName & message:Sample
That is all about it. Before we sign off, remember that the world of Android development is full of hidden gems and ingenious tricks. Given options work till latest Android Studio G. If you've got some secret logcat filtering sorcery up your sleeve, don't be shy – share it in the comments! Happy coding, and may your lines of code always compile with a sprinkle of developer magic ✨😇.
Top comments (0)