Skip to content

Published · Updated

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. adb logcat prints those log messages in your terminal; Android Studio's Logcat window (View, Tool Windows, Logcat) shows the same output with filters, if you have the SDK installed.

Syntax ​

bash
adb logcat [options] [tag:priority ...]
OptionWhat it does
-dPrints the log so far and stops, instead of following it
-cClears the log
-b crashShows only the crash buffer; -b all shows every buffer
--pid=1234Shows only one process's messages
-t 200Prints only the last 200 lines
-v colorColours each line by priority; the default format is threadtime
-e regexShows only lines that match a regular expression

Options depend on the phone's Android version; adb logcat --help lists the ones a phone has.

Read a log line ​

The default output format, threadtime, gives every line the same fields:

text
11-22 10:41:07.512  4321  4350 E AndroidRuntime: FATAL EXCEPTION: main
FieldHereMeaning
Date and time11-22 10:41:07.512When the message was written, on the phone's clock
PID4321The process that wrote it, one per running app
TID4350The thread inside that process
PriorityEThe level, from V verbose to F fatal
TagAndroidRuntimeWho wrote it: an app's own tag, or a system component
MessageFATAL EXCEPTION: mainThe text itself

Change the format with -v: brief, process, tag, thread, raw, time, threadtime and long are the formats, and modifiers such as color, year, UTC and epoch add to them, for example adb logcat -v time,color.

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)

The ADB command builder writes these filters for you: pick Read the log, name your tags, an app, a regular expression or a buffer, and copy the command for bash or PowerShell.

Save the log to a file ​

bash
adb logcat -d > log.txt
powershell
adb logcat -d | Out-File -Encoding utf8 log.txt

Plain > in Windows PowerShell 5.1 writes UTF-16 text, which some editors and tools read badly; Out-File -Encoding utf8 writes ordinary UTF-8.

Log buffers: where the log is kept ​

The phone keeps its log in memory, in several ring buffers of fixed size, so the oldest lines are dropped as new ones arrive and the log starts empty after a restart. -b chooses the buffers to read:

BufferWhat it holds
mainMost app and system log messages
systemMessages from Android's system services
crashCrash reports
eventsBinary system events, printed as text
radioMobile network and telephony messages
defaultmain, system and crash together; what plain adb logcat reads
allEvery buffer

Read several at once with a comma (adb logcat -b main,radio). adb logcat -g prints each buffer's size and adb logcat -G 16M makes the buffers bigger, so a crash stays in the log longer. Reading the log needs no root, but an app on the phone may read only its own lines unless it is granted READ_LOGS.

Investigate a crash: find out why an app crashed ​

  1. Clear the log with adb logcat -c, then make the app crash again.
  2. Run adb logcat -b crash -d and look for FATAL 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.
  3. If the app froze instead of closing, search the main log for ANR in followed by your app's package name.
  4. For a full picture, adb bugreport report.zip collects 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"
done
powershell
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. Logcat, APKs and a shell on many phones shows that page, and Android app testing on real devices where the log fits in a test run.

Free for up to 3 phones, with no account. Pro adds workflows, schedules and AI for up to 25 phones from $16 a month + VAT (including 300 cloud phone minutes every month).

Common errors and fixes ​

ProblemWhat it meansFix
- waiting for device -adb sees no phone and waits for oneConnect the phone; see adb devices
Nothing shows with --pidThe app was not running, so pidof found no processOpen the app first, then run the command
The crash is no longer in the logThe log buffer is full and old lines were droppedRead the log right after the crash, or make the buffer bigger with adb logcat -G 16M
adb: more than one device/emulatorSeveral phones are connectedChoose one with -s and its serial number

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 see the log in Android Studio instead of a terminal?

Yes. Android Studio's Logcat window (View, Tool Windows, Logcat) shows the same log messages from a connected phone or emulator, with filters by app, tag and level. adb logcat is the command line tool behind the same output, handy when Android Studio is not installed.

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 $16 a month + VAT (including 300 cloud phone minutes every month).