LinuxCommandLibrary

adb-logcat

View Android system and app logs

TLDR

Display system logs

$ adb logcat
copy

Display lines that match a reg[e]x
$ adb logcat -e [regex]
copy

Display logs for a tag in a specific mode ([V]erbose, [D]ebug, [I]nfo, [W]arning, [E]rror, [F]atal, [S]ilent), filtering other tags
$ adb logcat [tag]:[mode] *:S
copy

Display logs for React Native applications in [V]erbose mode [S]ilencing other tags
$ adb logcat ReactNative:V ReactNativeJS:V *:S
copy

Display logs for all tags with priority level [W]arning and higher
$ adb logcat *:W
copy

Display logs for a specific PID
$ adb logcat --pid [pid]
copy

Display logs for the process of a specific package
$ adb logcat --pid $(adb shell pidof -s [package])
copy

Color the log (usually use with filters)
$ adb logcat -v color
copy

SYNOPSIS

adb logcat [options] [filter-specs]

PARAMETERS

-a
    Print all buffers (default: all)

-b <buffer>
    Request alternate buffer: main, system, radio, events, crash, or default

-B <buffer>
    Request alternate buffer with bigger size

-c
    Clear (flush) entire log and exit

-C
    Color output

-d
    Dump log and exit (non-blocking)

-D
    Dump log decoded and exit

-e <expr>
    Print lines matching regex <expr>

-f <filename>
    Log to file <filename> (default: stdout)

-g
    Get size of log ring buffer and exit

-h
    Display help

-i
    Print row IDs for messages

-l <prio>
    Print only <prio> level or higher (numeric)

-m <count>
    Set rotation size of log

-n <count>
    Number of rotations for log size

-P <file>
    Save process/thread IDs to <file>

-q
    Don't suppress ASCII control chars

-r <kbytes>
    Rotate log every <kbytes> (16 default)

-s <tag>[:<prio>]
    Print logs for <tag> at <prio>

-S <file>
    Save logs in binary to <file>

-t <count>
    Print most recent <count> lines (with -d)

-T <count>
    Print most recent <count> lines (no -d)

-u <prio>
    Update log to given priority (numeric)

-v <format>
    Log format: brief, process, tag, thread, threadtime, long, raw, etc.

-w
    Recover from bad headers

DESCRIPTION

adb logcat is a powerful command-line tool in the Android Debug Bridge (ADB) suite for viewing, filtering, and dumping log messages from Android devices or emulators. It captures real-time logs from multiple sources including kernel ring buffers, applications, system services, radio, and crash reports. Logs are prioritized and color-coded: Verbose (V, gray), Debug (D, green), Info (I, blue), Warn (W, yellow), Error (E, red), Fatal (F, purple), and Silent (S, suppressed).

Primarily used for debugging apps and system issues, it streams continuously by default (Ctrl+C to stop). Developers filter by tags, priorities, PIDs, or regex to isolate relevant output. Output formats range from brief to detailed timestamps. It supports writing to files, rotation for large logs, and clearing buffers. Essential for Android development, it helps trace crashes, ANRs, and performance problems without rooting the device.

CAVEATS

Requires ADB installed, device connected via USB/Wi-Fi, and USB debugging enabled.
Verbose output can overwhelm terminals or impact device performance.
Multiple devices need -s serial selector.

LOG PRIORITIES

V/Verbose, D/Debug, I/Info, W/Warn, E/Error, F/Fatal, S/Silent.
Use like *:E to filter errors.

FILTER SPECS

Syntax: <tag>:<priority>
Examples: ActivityManager:I, package:com.example*:S, *:E (all errors).

COMMON BUFFERS

main: app logs; system: HAL/services; radio: telephony; events: kernel events; crash: crashes.

HISTORY

Part of Android SDK platform-tools since Android 1.0 (2008). Evolved with multi-buffer support in Android 4.0+, format options, rotation in later versions for better debugging.

SEE ALSO

adb(1), dmesg(1), journalctl(1)

Copied to clipboard