Help us understand the problem. What is going on with this article?

Android Studio Logcat regex expressions for efficient debugging

More than 1 year has passed since last update.

Logcat provides several default filter options (Verbose, Info, Debug etc) and a simple pattern match filter, but the regex filter is the most powerful option for customizing logcat output. Here, I provide 3 useful patterns that have been frequently used to search the logcat more efficiently.

1. Basic INCLUDE filter:

(logging|FA)

where logcat will only show lines containing the expressions separated by "|" (case-insensitive).

For example, "logging" may be a unique log identifier for your application, and FA is the output from the Firebase Analytics library

2. INCLUDE exact string filter (case-sensitive)

(?i)\bFA\b

here, we find logs that match FA exactly e.g. FA, FA-SVC from the Firebase Analytics library, and not any line that includes FA, Fa, fa etc

3. EXCLUDE filter by message type/source

Alternatively, if we want to display most of the logs (because we want to observe any unexpected library crashes or device warnings), it is better to EXCLUDE only those messages we can confidently ignore for the current session.

e.g.

^(?:(?!D/|I/|E/|W/|V/|Wifi|audio_hw_extn).)*$\r?\n?

where

  • E/ corresponds to Error messages, I/ corresponds to Info messages, etc..
  • Wifi, audio_hw_extn corresponds to any message containing these common keywords

Examples of message sources that frequent pollute the logcat and may not be useful for debugging include:
- GnssLocationProvider
- Bundle
- WifiService
- audio_hw_extn
- sensors-hal
- FA|FA-SVC (verbose logging from Firebase Analytics, if not disabled in the application code)

One could also copy their un-filtered logcat to an online text analyzer e.g. https://www.online-utility.org/text/analyzer.jsp to find the most common sources of logs.

cayozin
iOS/Android development (Swift/C++/Java/Kotlin/XML/Javascript), backend (php/mySQL) and Machine Learning (Python/Scala)
ayudante
いつもユーザー中心で技術者とコンサルタントがとことん考え抜く それがアユダンテです
https://ayudante.jp/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした