Start Service Save Android System log

Source: Internet
Author: User

As an Android development engineer, there is a bug is not a log and distress, the following I am provides a set of automatic saving log method for everyone to learn from:

First, in the product catalog of Init. Xxx.rc file, add the appropriate service,

# Start Log service
Start LOGD

On property:service.logcat.enable=1
Start Logcat_service

On property:service.logcat.enable=0
Stop Logcat_service

# Log Services
Service Logcat_service/system/bin/logcat-b system-b events-b main-b radio-k-n 10-v threadtime-r5000-f/data/Logs /log.0/l
User root
Group Log System
Class Main
Disabled

Service logd/system/bin/sh/system/bin/logd.sh
User System
Group Log
OneShot

Then, add the script file logd.sh under the target platform's system/bin, process the stored log log, and set the properties, turn on Logcat_service,

#!/system/bin/sh

#
# Global folder & cmd params
#

Output_dir=/data
Log=logs
index=2

log_dir[0]= $OUTPUT _dir/$LOG/log.0
log_dir[1]= $OUTPUT _dir/$LOG/log.1
log_dir[2]= $OUTPUT _dir/$LOG/log.2

Rm=rm
mv= "MV"
Mkdir=mkdir
Umask=umask


# Set Default Permission 0775
$UMASK 002

# Init The three folders

I=0
While ["$i"-le "$index"]
Do
$MKDIR-P ${log_dir[$i]}
i=$ (($i + 1))
Done

# Transfer The three folders
((i= $index-1))
$RM-R ${log_dir[$index]}/*
While ["$i"-ge "0"]
Do
$MV ${log_dir[$i]}/* ${log_dir[$i +1]}
i=$ (($i-1))
Done
$RM-R ${log_dir[0]}/*

# Start Logcat Service
SetProp service.logcat.enable 1

Mkdir/data/www
Cp-r/system/var/www//data/
Ln-s/storage/external//data/www/sdcard


Let's clap, gentlemen. ~ ~ ~

Start Service Save Android System log

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.