extracting-logs-with-logcat

Capture Android device logs with adb logcat using buffer and tag filters.

303|10|Updated May 15, 2026
One-click install
npx skills add https://github.com/skydoves/android-testing-skills --skill extracting-logs-with-logcat
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: extracting-logs-with-logcat
Source: https://github.com/skydoves/android-testing-skills/tree/main/adb/observability/extracting-logs-with-logcat
Command: npx skills add https://github.com/skydoves/android-testing-skills --skill extracting-logs-with-logcat

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

When an Android test fails on CI or only reproduces on-device, you need the right device logs to pinpoint what happened without drowning in irrelevant output.

Core Features & Use Cases

  • Stream or snapshot logs: Use adb logcat for live streaming or adb logcat -d to dump and exit for CI artifacts.
  • Target the correct buffer and severity: Select buffers like main, system, and crash, then filter by tag/priority using expressions such as MyApp:D *:S.
  • Make logs machine- and CI-friendly: Use structured formats (-v json on Android 11+), time/PID filters (-T, -t, --pid), and rotation/persistence flags (-f, -r, -n, -G, -g), plus an R8 rule to strip Log.d in release builds.
  • Use cases: Reproduce-and-dump on failure, isolate system/crash issues, debug “missing logs” via buffer sizing, and prevent sensitive debug logging from shipping.

Quick Start

Run: adb logcat -c && ./run-scenario.sh && adb logcat -d -b crash -v threadtime > artifacts/crash.txt

Frequently Asked Questions about extracting-logs-with-logcat

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I capture Android logcat output for CI test failures without flooding the artifacts?

Use `adb logcat -d` to dump and exit for CI artifacts, applying tag and priority filters like `MyApp:D *:S` to isolate specific output. This captures only the relevant logs from the correct buffer without continuous streaming.

What is the best way to filter adb logcat by tag and priority to debug on-device issues?

Filter adb logcat by using expressions such as `MyApp:D *:S` to show debug logs for a specific tag while silencing everything else. Select the correct buffer with `-b` to target main, system, or crash logs.

Can I get structured JSON logs from adb logcat for automated parsing?

Yes, you can get structured JSON logs by using the `-v json` format flag on Android 11 and above. This makes the log output machine-readable and CI-friendly for automated analysis pipelines.

How do I prevent sensitive debug logs from shipping in Android release builds?

Prevent sensitive logging by applying an R8 rule with `-assumenosideeffects` for `android.util.Log` methods like `v`, `d`, and `i`. This safely strips debug logging from your release builds.

Why am I missing logcat entries and how do buffer sizes affect log capture?

Missing logcat entries often result from insufficient log buffer sizing. Use buffer rotation and persistence flags like `-G` to resize the buffer and `-f`, `-r`, `-n` to ensure logs are properly captured and retained.