Appearance
adb logcat: read, filter and save Android logs
In short: adb logcat shows an Android phone's system log on your computer, including messages and crash reports from apps. Run adb logcat to follow it live, adb logcat -d to print what is there and stop, and adb logcat -c to clear it. Filter by priority with *:E, by app with --pid, and save it with adb logcat -d > log.txt.
Logcat is where Android and every app write what they are doing, so it is the first place to look when an app misbehaves on a phone.
Syntax
bash
adb logcat [options] [tag:priority ...]| Option | What it does |
|---|---|
-d | Prints the log so far and stops, instead of following it |
-c | Clears the log |
-b crash | Shows only the crash buffer; -b all shows every buffer |
--pid=1234 | Shows only one process's messages |
-t 200 | Prints only the last 200 lines |
-v color | Colours each line by priority; the default format is threadtime |
-e regex | Shows only lines that match a regular expression |
Options depend on the phone's Android version; adb logcat --help lists the ones a phone has.
Filter by priority and tag
Priorities run from lowest to highest: V verbose, D debug, I info, W warning, E error, F fatal, and S silent, which hides everything. A filter is tag:priority; * means every tag.
bash
# Errors and worse, from every tag (quote * so the shell leaves it alone)
adb logcat '*:E'
# Your app's tag at debug and above, ActivityManager at info, nothing else
adb logcat ActivityManager:I MyApp:D '*:S'
# Only one app, while it is running
adb logcat --pid=$(adb shell pidof -s com.example.app)Save the log to a file
bash
adb logcat -d > log.txtpowershell
adb logcat -d | Out-File -Encoding utf8 log.txtPlain > in Windows PowerShell 5.1 writes UTF-16 text, which some editors and tools read badly; Out-File -Encoding utf8 writes ordinary UTF-8.
Find out why an app crashed
- Clear the log with
adb logcat -c, then make the app crash again. - Run
adb logcat -b crash -dand look forFATAL EXCEPTION. The lines below it are the stack trace: the first line names the error, and the lines that mention your app's classes show where it happened. - If the app froze instead of closing, search the main log for
ANR infollowed by your app's package name. - For a full picture,
adb bugreport report.zipcollects the logs and much more in one file.
On many phones at once
When a test fails on some phones only, save each phone's log under its own name:
bash
for s in $(adb devices | awk 'NR>1 && $2=="device" {print $1}'); do
adb -s "$s" logcat -d > "log-${s//[:\/]/_}.txt"
donepowershell
adb devices | Select-Object -Skip 1 | ForEach-Object {
$serial, $state = $_ -split '\s+'
if ($state -eq 'device') { adb -s $serial logcat -d | Out-File -Encoding utf8 "log-$($serial -replace '[:\\/]', '_').txt" }
}In BenchFleet, each phone's page has its logcat next to the live screen, on every plan, so you can watch the log while you reproduce the problem by hand.
Free for up to 3 phones, with no account. Pro adds workflows, schedules and AI for up to 25 phones from £12 a month + VAT.
Common errors and fixes
| Problem | What it means | Fix |
|---|---|---|
- waiting for device - | adb sees no phone and waits for one | Connect the phone; see adb devices |
Nothing shows with --pid | The app was not running, so pidof found no process | Open the app first, then run the command |
| The crash is no longer in the log | The log buffer is full and old lines were dropped | Read the log right after the crash, or make the buffer bigger with adb logcat -G 16M |
adb: more than one device/emulator | Several phones are connected | Choose one with -s and its serial number |
Related
- adb shell: restart the app or change settings while you watch the log.
- adb install: put a fixed build on the phone.
- adb screenshot: capture what was on screen when it went wrong.
- All ADB commands and the ADB command builder.
Questions
What is the adb command for logcat?
adb logcat. On its own it follows the log live until you press Ctrl+C; adb logcat -d prints the log so far and stops, which is what you want when saving it to a file.
How do I filter logcat by app?
Give logcat the app's process ID, which pidof finds while the app is running, for example adb logcat --pid=$(adb shell pidof -s com.example.app). Filtering by your app's own log tags, such as MyApp:D *:S, also works.
How do I save logcat to a file?
In bash or zsh, run adb logcat -d > log.txt. In PowerShell, run adb logcat -d | Out-File -Encoding utf8 log.txt, so the file is plain UTF-8 text.
How do I clear logcat?
Run adb logcat -c. It empties the log buffers, so the next adb logcat shows only new messages, which makes a fresh test run easier to read.
How do I find out why an app crashed?
Run adb logcat -b crash -d right after the crash and look for FATAL EXCEPTION; the lines after it are the stack trace that names the error and where it happened. For a frozen app, look for ANR in the main log, or collect everything with adb bugreport.
Can I read the log on the phone without a computer?
Log reader apps can, but Android lets them read other apps' logs only after you grant them the READ_LOGS permission once, with adb shell pm grant and the app's package name.
Start with the Free plan
Free for up to 3 phones, with no account. Pro adds workflows, schedules and AI for up to 25 phones from £12 a month + VAT.
- A full refund within 14 days of your first payment
- Starts in Local mode, with no telemetry or analytics
- Made by WOODCOMMERCE LTD, a company registered in the UK