首先看看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.

Option Description
-b  Loads an alternate log buffer for viewing, such as event 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  Writes log message output to . The default is stdout.
-g Prints the size of the specified log buffer and exits.
-n  Sets the maximum number of rotated logs to . The default value is 4. Requires the -r option.
-r  Rotates the log file every of output. The default value is 16. Requires the -f option.
-s Sets the default filter spec to silent.
-v  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基本够用了。



更多相关文章

  1. [Android UI] listview 自定义style
  2. Android xml资源文件中@、@android:type、@*、?、@+的含义和区别
  3. android 布局文件详解
  4. android支持的media文件格式--MediaFile
  5. Android xml资源文件中@、@android:type、@*、?、@+含义和区别
  6. Android 资源文件中@、@android:type、@*、?、@+含义和区别
  7. .NET应用函数定义与用法汇总
  8. 异常设计函数定义与用法汇总
  9. asp.net core实例教程之异常处理与静态文件教程

随机推荐

  1. Android源码repo init及repo sync小记
  2. 手动滑动TextView超出的内容
  3. Android中使用xml保存数据(xml文件序列化
  4. .NET跨平台开发之Xamarin.Android介绍与
  5. windows 下 android 使用ant自动打包
  6. Android总结篇系列:Android广播机制----学
  7. Android JNI中记录log
  8. Android:删除预装应用
  9. android 决TextView中MaxLines与ellipsiz
  10. 解决国内android sdk无法更新,google不能