Android logcat log size -- Android logcat log 大小限制如何设置

首先看看Android对logcat 的介绍:

logcat

The Android logging system provides a mechanism for collecting and viewing system debug output. Logs from various applications and portions of the system are collected in a series of circular buffers, which then can be viewed and filtered by the logcat command. You can use logcat from an ADB shell to view the log messages.

For complete information about logcat options and filtering specifications, see Reading and Writing Logs.

For more information on accessing logcat from DDMS, instead of the command line, see Using DDMS.

Syntax

[adb] logcat [<option>] ... [<filter-spec>] ...

You can run logcat as an adb command or directly in a shell prompt of your emulator or connected device. To view log output using adb, navigate to your SDK platform-tools/ directory and execute:

$ adb logcat

You can create a shell connection to a device and execute:

$ adb shell
# logcat

Options

The following table describes the command line options of logcat.

OptionDescription
-b <buffer>Loads an alternate log buffer for viewing, such as event or radio. The main buffer is used by default. See Viewing Alternative Log Buffers.
-cClears (flushes) the entire log and exits.
-dDumps the log to the screen and exits.
-f <filename>Writes log message output to <filename>. The default is stdout.
-gPrints 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 -f option.
-sSets 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.

举例说明:init.rc 里可以定义将logcat + logcat-radio 的log都指定到aplog文件中,20个文件循环写

service ap_logfs /sbin/logcat -b system -b events -b main -b radio -n 20 -r 5000 -v threadtime -f /logs/aplog

    disabled


service apk_logfs /sbin/logcat -b system -b events -b main -b radio -n 20 -r 5000 -v threadtime -f /logs/aplog -K
    disabled


100M的log基本够用了。



  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值