Use Logcat to record logs to files and logcat logs
In some development stages, a small part of the product has been distributed out. In the case of problems, we hope that users can send the Logcat logs at that time to programmers for analysis, here we will introduce a clever way to use the logcat command line to record logs without writing the log record code by yourself.
The Android shell provides a logcat command to view system logs. This command also supports log filtering and logging to files, it also supports Automatic Log File scrolling and controlling the log file size. Therefore, when the system starts, we can use Runtime to call the logcat command and start a process to record the logs we send through Logcat to the file, the following describes common parameters:
-V threadtime log output format, which can be brief process tag thread raw time threadtime long. -F/sdcard/filepath/log file output path-r51200 maximum size of a single log file: 51200kbytes-n 3 maximum size of 3 log files-s TAG1: V TAG2: D TAG3: w. Filter by TAG and level