Android Tutorials - Herong's Tutorial Examples
Dr. Herong Yang, Version 2.1

"adb logcat" Command Options and Log Buffers

This section describes the 'adb logcat' command options to dump and manage log buffers: main, events, and radio. An example is given to dump logs into a set of rotated log files.

To better use the "adb logcat" command, we need to look at its options:

  • "adb logcat -b <buffer>" - Loads an alternate log buffer for viewing, such as event or radio. The main buffer is used by default. There are 3 log buffers on the Android system: "main", "events", and "radio". The default buffer is "main".
  • "adb logcat -c" - Clears (flushes) the entire log and exits.
  • "adb logcat -d" - Dumps the log to the screen and exits.
  • "adb logcat -f <filename>" - Writes log message output to a file. The default is the "stdout - Standard Output".
  • "adb logcat -g" - Prints the size of the specified log buffer and exits.
  • "adb logcat -n <count>" - Sets the maximum number of rotated logs to <count>. The default value is 4. Requires the -r option.
  • "adb logcat -r <kbytes>" - Rotates the log file every <kbytes> of output. The default value is 16. Requires the -f option.
  • "adb logcat -s" - Sets the default filter spec to silent.
  • "adb logcat -v <format>" - Sets the output format for log messages. The default is brief format.

Here are two examples of using "adb logcat" options:

1. To show the size of the default log buffer (main) and clear it on the connected device:

C:\herong\>\local\android-sdk-windows\platform-tools\adb logcat -g
/dev/log/main: ring buffer is 64Kb (63Kb consumed), max entry is \
   4096b, max payload is 4076b

C:\herong\>\local\android-sdk-windows\platform-tools\adb logcat -c

C:\herong\>\local\android-sdk-windows\platform-tools\adb logcat -g
/dev/log/main: ring buffer is 64Kb (0Kb consumed), max entry is \
   4096b, max payload is 4076b

2. To continuously dump log entries to a set of 8 rotated log files of 1 MB each on the file system of the connected device:

C:\herong\>\local\android-sdk-windows\platform-tools\adb logcat \
   -f /sdcard/Download/Android.log -r 1024 -n 8

(leave it running)

See next tutorials on how to control the format of the "adb logcat" output.

Last update: 2012.

Table of Contents

 About This Book

 Installation of Android SDK R17 and Emulator

 Installing JDK 1.7 on Windows System

 Installing Apache Ant 1.8 on Windows System

 Developing First Android Application - HelloAndroid

 Android Application Package (APK) Files

 Android Debug Bridge (adb) Tool

 Android File Systems

 AboutAndroid - Application to Retrieve System Information

 android.app.Activity Class and Activity Lifecycle

 View Objects and Layout Resource Files

Using "adb logcat" Command for Debugging

 "adb logcat" Command - Displaying System Logs

"adb logcat" Command Options and Log Buffers

 "adb logcat -v" Command - Log Format Control

 "adb logcat" Command Arguments - Output Filters

 Using "adb logcat" Command to Track the Lifecycle of an Application

 Java Exceptions in AndroidRuntime Error Log

 Build Process and Package File Content

 Building Your Own Web Browser

 Android Command Line Shell

 Android Phone - LG-P925g

 USB Debugging Applications on LG-P925g Phone

 Android Tablet - LG-V905R

 USB Debugging Applications on LG-V905R Tablet

 References

 PDF Printing Version

Dr. Herong Yang, updated in 2012
Using "adb logcat" Command for Debugging