When an app crashes, a feature misbehaves, or a battery‑draining service appears, the Android logcat buffer contains the low‑level details you need to diagnose the problem. By default the buffer lives only in RAM and disappears after a reboot. Saving it to a file gives you a permanent record that you can share with developers, archive for later analysis, or use to spot patterns.
C:\adb on Windows or ~/adb on macOS/Linux.PATH (optional but convenient). On Windows, edit Environment Variables → Path; on macOS/Linux, add export PATH=$PATH:~/adb to ~/.bash_profile or ~/.zshrc.adb version. You should see the version number, confirming the installation.adb devices. You should see a line like 0123456789ABCDEF device.unauthorized, look at the phone – a dialog asks to “Allow USB debugging”. Tap Allow and optionally check “Always allow from this computer”.It is safest to keep the log file outside any synced cloud folder (e.g., Dropbox) because logcat may contain personal identifiers (IMEI, device IDs, usernames). Create a dedicated folder, for example:
mkdir -p ~/android-logs
We will write the file system.log into this directory.
cd ~/android-logs
logcat command. It streams the full buffer to a file and rotates the file every 10 MB, keeping the three most recent segments.adb logcat -v time -b all -G 10M | rotatelogs -L system.log -l 10M -n 3
If rotatelogs is not available (common on Windows), use the built‑in logcat option -r for size‑based rotation:
adb logcat -v time -b all -r 10240 -n 3 -f system.log
Explanation of the flags:
-v time – prepend each line with a timestamp, making later analysis easier.-b all – capture every buffer (main, system, radio, events, crash) for a complete picture.-r 10240 – rotate the file after 10 240 KB (≈10 MB).-n 3 – keep three rotated files (system.log, system.log.1, system.log.2).-f – direct output to the specified file instead of stdout.Full‑buffer logging can be noisy. If you are interested in a particular app or tag, add a filter expression after the command. Example – capture only logs from the package com.example.myapp and errors from the system:
adb logcat -v time -b all -r 10240 -n 3 -f system.log \
*:W com.example.myapp:D
Here *:W sets the default priority to Warning, while com.example.myapp:D keeps Debug level messages for the chosen app.
Ctrl+C to stop the command.head -n 20 system.log
You should see timestamped lines that mention your app’s package name or the system component you interacted with. If the file is empty, double‑check that USB debugging is still enabled and that the device is listed by adb devices.
For developers who need logs every time the device boots, you can create a simple batch (Windows) or shell (macOS/Linux) script and add it to the computer’s startup routine.
start-log.bat)@echo off
set LOGDIR=%USERPROFILE%\android-logs
if not exist "%LOGDIR%" mkdir "%LOGDIR%"
adb logcat -v time -b all -r 10240 -n 3 -f "%LOGDIR%\system.log" *:W
start-log.sh)#!/bin/bash
LOGDIR="$HOME/android-logs"
mkdir -p "$LOGDIR"
adb logcat -v time -b all -r 10240 -n 3 -f "$LOGDIR/system.log" *:W
Make the script executable (chmod +x start-log.sh) and add it to your login items.
When you have captured enough data, pull the files to a convenient location:
adb pull ~/android-logs/system.log ~/Desktop/
adb pull ~/android-logs/system.log.1 ~/Desktop/
adb pull ~/android-logs/system.log.2 ~/Desktop/
On Windows replace the paths with the appropriate drive letters. Once on your PC you can open the logs with any text editor, import them into tools like Android Log Viewer, or feed them to grep for keyword searches.
adb devices
adb kill-server && adb start-server.-b all flag; without it you only get the “main” buffer which might be empty if the issue is in the radio or system layer.adb logcat -G 16M to increase it before starting capture.grep -v "IMEI" system.log > cleaned.log removes lines containing the keyword.-p flag to limit the output to specific tags only.adb logcat -c to free RAM.Once you have a log file, you can:
Exception or FATAL EXCEPTION to locate crashes.W/ (warning) lines that precede a slowdown.Remember that the most useful logs are those captured exactly at the moment the problem occurs – start the capture before you trigger the issue.
-b all flag; in that case drop it and accept a less‑complete log.








