How logcat filtering works
adb logcat shows every entry in the buffers it reads, unless a filter
expression hides some of them. If you pass no * rule and no
-s, the default for all tags is *:V, so every tag stays
visible.
Priority levels
Every log entry has a priority. From lowest to highest: V (verbose),
D (debug), I (info), W (warning),
E (error), F (fatal) and S (silent). Nothing is
ever printed at S, so a tag set to S shows no output.
A filter tag:priority shows that tag at the given priority or higher.
MyTag:D shows MyTag at D, I, W, E and F. *:E shows only
error and fatal entries for every tag. A tag with no priority, such as
MyTag, means MyTag:V. A bare * means
*:D.
Showing only some tags
adb logcat MyTag:V does not limit the output to MyTag. The default for
all other tags is still verbose, so you see every log.
Add *:S: adb logcat MyTag:V '*:S'. The * rule
sets the priority for every tag that has no rule of its own. Setting it to
S hides all of them, so only MyTag is left. The position of the
* rule in the list does not matter. If the same tag appears twice, the
later rule wins.
Quote the * rule in bash and zsh. zsh, the default shell on macOS,
reads a bare *:S as a file pattern and stops with
zsh: no matches found: *:S. bash passes it through only when no file
matches. PowerShell and cmd pass it to adb as is.
The -s option
-s sets the default filter to silent, like *:S. So
adb logcat -s MyTag MyOtherTag is the same as
adb logcat MyTag:V MyOtherTag:V '*:S'. Build mode above writes the explicit
form.
Filtering by app process with pidof
To see only your app's logs, whatever tag they use, filter by process ID:
adb logcat --pid=$(adb shell pidof com.example.app)
$(adb shell pidof X) is command substitution in bash and zsh. The shell
runs the inner command and puts its output, the PID, into the outer command. The
result is a command like adb logcat --pid=12345.
A new app process gets a new PID, so run the command again after the app restarts.
If the app is not running, pidof prints nothing and
--pid gets no value. Start the app first.
PowerShell uses the same $(...) form. Plain parentheses do not work here:
in an argument, PowerShell treats (...) after other text as a separate
argument. cmd has no command substitution. Run adb shell pidof com.example.app
first and paste the PID into the second command. The builder above switches the syntax
for the shell you pick.
Output formats
The default output format is threadtime. It shows the date, time, PID,
thread ID (TID), priority, tag and message:
05-08 14:23:15.243 12345 12350 D MyTag: some message
brief shows only priority, tag and PID:
D/MyTag(12345): some message. time adds the date and time
to that. tag shows priority and tag. raw shows the message
with no metadata. Pick one with -v, for example
adb logcat -v brief.
Buffers
logd keeps several log buffers. Without -b, logcat reads
main, system and crash.
main: most app logs. It does not contain system or crash messages.system: messages from the Android OS.crash: crash logs.events: interpreted binary system event messages.radio: radio and telephony messages.all: every buffer.
Read several buffers by repeating -b or with a comma-separated list:
adb logcat -b main -b crash or adb logcat -b main,crash.
Things to watch for
Tag matching is exact and case-sensitive. MyTag:V does not match a tag
logged as mytag. Copy the tag from the code that logs it.
To match text in the message, use adb logcat -e <expr> (long form
--regex). It keeps only lines whose message matches the regular
expression. You can also pipe the output through grep:
adb logcat | grep -i "exception".
adb logcat -c clears the log on the device and exits. The cleared
entries are gone. Run it before you reproduce a bug if you only want the new lines.
With several devices connected, pick one with -s before the command:
adb -s <serial> logcat. The serial comes from
adb devices. This -s belongs to adb. The
-s after logcat is the silent filter described above.
Example commands
Crashes: adb logcat -b crash '*:E'. Reads only the crash buffer and shows
entries at error or higher.
One tag: adb logcat MyFeatureTag:V '*:S'. Shows only MyFeatureTag, at
verbose and higher.
Firebase Analytics: the Firebase docs enable verbose logging with
adb shell setprop log.tag.FA VERBOSE and
adb shell setprop log.tag.FA-SVC VERBOSE, then read the tags with
adb logcat -v time -s FA FA-SVC.
Save to a file: adb logcat -d > bug-report.txt. -d dumps
the log and exits, so you get a finite file. For a full device report with
dumpsys, dumpstate and logcat output, use
adb bugreport.
One app: adb logcat --pid=$(adb shell pidof com.example.app). Shows every
line from that process, whatever the tag.