extracting-logs-with-logcat

Extract and filter Android device logs using adb logcat buffers, filters, and rotation.

1|Updated Jul 6, 2026
One-click install
npx skills add https://github.com/citytexi/team-yg-pesonal-agent --skill extracting-logs-with-logcat-citytexi
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: extracting-logs-with-logcat
Source: https://github.com/citytexi/team-yg-pesonal-agent/tree/main/.claude/skills/extracting-logs-with-logcat
Command: npx skills add https://github.com/citytexi/team-yg-pesonal-agent --skill extracting-logs-with-logcat-citytexi

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Debugging Android test failures and CI repros requires reading device logs, but naive approaches like adb logcat | grep MyApp saturate the USB transport, miss logs in non-default buffers, and produce unusable CI artifacts. This Skill provides the correct logcat invocation patterns for every capture scenario. ## Core Features & Use Cases - Buffer and filter mastery: Select the right ring buffer (main, system, crash, events, radio, kernel) and apply tag/priority filter expressions like MyApp:D *:S so filtering happens on-device, not via host-side grep. - CI capture-on-failure: The clear-run-dump idiom (adb logcat -c, run scenario, adb logcat -d) plus structured -v json output for machine ingestion with jq. - Advanced capture control: PID-bound streaming with pidof -s re-resolution loops, time/count filters (-T, -t), file rotation (-f, -r, -n), buffer resizing (-G), and the R8 -assumenosideeffects rule to strip Log.d from release builds. - Use Case: A test fails on CI and you need actionable logs. Clear the buffer, rerun the scenario, then dump main, crash, and events buffers with threadtime formatting into the artifact archive. ## Quick Start Ask the AI to dump only your app's debug logs from an Android device into a file for a failing CI test, filtering out all other tags.

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 filter adb logcat to show only my app's logs?▼

Use a logcat filter expression like `adb logcat MyApp:D *:S`, which shows your tag at Debug level and silences everything else. Filter at the logcat level rather than piping to grep, since host-side grep makes the device send every line over the transport. Quote the filter string in shell scripts so globbing does not eat the asterisk.

How do I capture logcat output to a file in CI?▼

Run `adb logcat -c` to clear the buffer, execute your test scenario, then run `adb logcat -d > artifacts/log.txt` to dump and exit. The `-d` flag takes a snapshot instead of streaming, which is the correct mode for CI capture-on-failure workflows.

What is the difference between logcat -t and -T flags?▼

`-t <count>` prints the last N entries and then exits, while `-T <count>` prints the last N entries and continues streaming. Using `-T` when you want a bounded tail causes the command to hang forever, so use `-t` for tail-and-exit behavior.

Does adb logcat -v json work on all Android versions?▼

No, the `-v json` format requires Android 11 (API 30) or higher on the device. On older versions it silently emits an empty stream. Stack it with `-v UTC -v year` for unambiguous timestamps in machine-ingested output.

Why do my app's logs disappear after the process restarts?▼

A `--pid` filter binds to a single process ID, so when Doze, an ANR, or a crash kills and restarts the app, the old PID no longer emits logs. Wrap the capture in a loop that re-resolves the PID with `adb shell pidof -s <pkg>` and restarts logcat.

How do I strip Log.d calls from a release Android build?▼

Add an R8 `-assumenosideeffects` rule for `android.util.Log` covering the `v`, `d`, `i`, and `isLoggable` methods in proguard-rules.pro. R8 then treats those calls as no-ops and removes them. Keep `w`, `e`, and `wtf` for production diagnostics, and never apply the rule to `kotlin.jvm.internal.Intrinsics`.