跪拜 Guibai
← All articles
Android

Android Studio's New Logcat Filter Syntax Is a Full Query Language

By 阿巴斯甜 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

The shift from GUI dropdowns to a composable query language means faster, more precise log triage. Developers who learn the syntax can combine package, tag, level, and message filters in one line instead of clicking through multiple menus.

Summary

The new Logcat in Android Studio drops the old dropdown-based filtering for a `field:value` query syntax. Exact matches use `tag:PermissionUtils`, regex fuzzy matching adds a tilde (`tag~:Permission`), and a leading dash excludes results (`-tag:System`). Multiple conditions combine with spaces, acting as a logical AND.

Built-in fields cover package name, tag, log level, message content, process name, and time window. The `package:mine` shortcut instantly isolates logs from the currently debugging app, cutting out system noise. Saved filter presets let teams reuse common queries without retyping.

For developers who find the new syntax unfamiliar, the old Logcat can be restored by unchecking "Enable new Logcat tool window" under Settings → Experimental → Logcat and restarting Android Studio.

Takeaways
Exact matching uses `field:value`; fuzzy regex matching uses `field~:value`; exclusion uses `-field:value` or `-field~:value`.
`package:mine` is a built-in shortcut that filters logs to only the currently debugging app.
Multiple conditions separated by spaces combine as a logical AND — all must match for a log line to appear.
Regex alternation with `|` lets a single filter match multiple tags or packages at once, such as `tag~:PermissionUtils|DataCenterUtils`.
Saved filter presets are accessible via the star button next to the filter input, eliminating repeated typing.
The old Logcat can be re-enabled by unchecking "Enable new Logcat tool window" in Settings → Experimental → Logcat and restarting Android Studio.
Conclusions

The new syntax turns Logcat filtering from a point-and-click UI into a composable mini-language, which rewards memorization but also makes saved presets essential for team consistency.

Requiring a tilde for regex (`tag~:`) while exact match is the default (`tag:`) inverts the expectation of most search interfaces, where substring matching is usually the default. This design choice prioritizes precision over convenience.

The `package:mine` shortcut is a one-liner that replaces what used to require multiple dropdown selections, suggesting Google recognized that filtering out system noise is the single most common Logcat operation.

Concepts & terms
Logcat key-value filter syntax
A query language in Android Studio's new Logcat that uses `field:value` pairs to filter log output. Fields include `package`, `tag`, `level`, `message`, `process`, `age`, and `is`. A tilde (`~`) after the colon enables regex matching; a leading dash (`-`) excludes matches.
package:mine
A built-in Logcat filter shortcut that automatically restricts log output to the package name of the app currently being debugged, filtering out all system and third-party process logs.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗