[Android] 关于Logcat我需要知道的事

本文详细介绍了Android开发中常用的logcat命令及其使用方法。包括如何设置logcat的过滤条件、输出格式、日志文件的保存及清除等操作。通过本文的学习,开发者可以更高效地利用logcat进行应用调试。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


# 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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值