In some stages of development, the product has been distributed in a small part, in the event of a problem, we hope that users can send the Logcat log also sent to the programmer for analysis, here is a clever use of the Logcat command line logging method, do not have to write the log records of the code.
Android Shell provides a logcat command, is used to view the system log, this command supports log filtering, logging to a file, and support automatic log file scrolling, control log file size. Therefore, when the system starts, we use runtime to invoke the Logcat command, start a process, you can send us through the Logcat log into the file, the following is the usual parameters:
-v threadtime日志输出的格式,有brief process tag thread raw time threadtime long这么几种可选。-f /sdcard/filepath/ 日志文件输出路径-r51200 单个日志文件最大大小51200kbytes-n 3 最大3个日志文件-s TAG1:V TAG2:D TAG3:W 根据TAG和级别进行过滤
Using Logcat to log records to a file