Read device logs
android_logcatFetch a filtered snapshot of Android device logs. After a crash, read the crash buffer for stack traces; filter by app, tag, or priority; clear before reproducing a bug for a clean read.
Instructions
Read logcat from the device, filtered down to what is actually relevant.
Returns a snapshot of the existing buffer and exits; it does not stream. Filter by package to see only your app's output — this is usually what you want after a crash, because the unfiltered buffer is mostly unrelated system noise.
Args:
serial (string, optional): target device
package_name (string, optional): show only lines from this app's process
tag (string, optional): show only this log tag
priority ('V'|'D'|'I'|'W'|'E'|'F'): minimum level (default: 'V', or 'E' when crashes_only is set)
crashes_only (boolean): read the crash buffer — fatal exceptions and ANRs. This buffer survives the process, so it works after the app has died (default: false)
lines (number): how many lines to return, 1-2000 (default: 200). Normally the most recent N; with crashes_only it is the first N of the crash, since that is where the exception and the top frames are
clear_only (boolean): wipe the buffer and return immediately without reading (default: false)
response_format ('markdown' | 'json')
Returns: { "lines": string[], "count": number, "truncated": boolean, "serial": string, "pid": number, "diagnosis": string }
'diagnosis' is present when a crash matches a known Android failure mode.
Examples:
Use when: the app crashed and you need the stack trace -> crashes_only=true, package_name="com.example.app"
Use when: watching your own Log.d output -> tag="MyTag"
Use when: reproducing a bug cleanly -> clear_only=true, reproduce it, then call again to read
Don't use when: you want to see the screen (use android_screenshot)
Error Handling:
Filtering by package uses the process id, which requires the app to be running. After a crash there is no process, so combine package_name with crashes_only — that path filters the crash buffer by name instead
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tag | No | Only show this log tag. | |
| lines | No | Most recent N lines to return. | |
| serial | No | Device serial from android_list_devices. Optional when exactly one device is connected; required when several are. | |
| priority | No | Minimum log priority: Verbose, Debug, Info, Warn, Error, Fatal. | |
| clear_only | No | Clear the log buffer and return immediately without reading. Use before reproducing a problem, then call again to see only what the reproduction produced. | |
| crashes_only | No | Read the crash buffer only (fatal exceptions, ANRs). | |
| package_name | No | Only show logs from this app's process. The app must be running. | |
| response_format | No | Output format: 'markdown' for human-readable, 'json' for machine-readable. | markdown |