# Definition of logcat
The following table describes the command line options of logcat.
| Option | Description |
|---|---|
-b <buffer> | Loads an alternate log buffer for viewing, such as events or radio. The main buffer is used by default. See Viewing Alternative Log Buffers. |
-c | Clears (flushes) the entire log and exits. |
-d | Dumps the log to the screen and exits. |
-f <filename> | Writes log message output to <filename>. The default is stdout. |
-g | Prints the size of the specified log buffer and exits. |
-n <count> | Sets the maximum number of rotated logs to <count>. The default value is 4. Requires the-r option. |
-r <kbytes> | Rotates the log file every <kbytes> of output. The default value is 16. Requires the -foption. |
-s | Sets the default filter spec to silent. |
-v <format> | Sets the output format for log messages. The default is brief format. For a list of supported formats, see Controlling Log Output Format. |
# logcat 会用到的设备节点
$ adb logcat -g
/dev/log/main: ring buffer is 256Kb (255Kb consumed), max entry is 5120b, max payload is 4076b
/dev/log/system: ring buffer is 256Kb (255Kb consumed), max entry is 5120b, max payload is 4076b
# logcat filter
我需要logcat打印处verbose,tag为ActivityManager的log。
$ adb shell logcat -s ActivityManager:V
# logcat log to file
# logcat set the log print format
# logcat clear (flush) the entire log and exit
# logcat request alternate ring buffer ('main', 'system', 'radio', or 'events')
# logcat
本文详细介绍了Android开发中常用的logcat命令及其使用方法。包括如何设置logcat的过滤条件、输出格式、日志文件的保存及清除等操作。通过本文的学习,开发者可以更高效地利用logcat进行应用调试。
1168

被折叠的 条评论
为什么被折叠?



