(34) Log management in development (how to remove all log logs when the application is published)

Source: Internet
Author: User

1, Android reasonable management log logs, in the development of the time to print out, at the time of release, all the log log off the method as follows: In order to facilitate the operation of the log need to customize a logger class and then develop all the log printing use this class. Below is the source code of logger class.

/*** Development of Log Management: * In the development of the log is often printed, but when we publish the project is not printing, if the printing will be a security problem or inefficient execution. * In order to facilitate the operation of log need to customize a log class and then in the development of the definition of the log class, * and then in the development phase of the following Log_level set to 6, so that all the log can be displayed, * at the time of release we set Log_level to 0, so that log does not display, Very convenient to manage the * **/ Public classLogger { Public Static intLog_level = 6;  Public Static intERROR = 1;  Public Static intWARN = 2;  Public Static intINFO = 3;  Public Static intDEBUG = 4;  Public Static intVERBOSE = 5;  Public Static voide (string tag, string msg) {if(Log_level >ERROR)        {LOG.E (tag, msg); }    }     Public Static voidW (string tag, string msg) {if(Log_level >WARN)        {LOG.W (tag, msg); }    }     Public Static voidI (string tag, string msg) {if(Log_level >INFO)        {LOG.I (tag, msg); }    }     Public Static voidd (string tag, string msg) {if(Log_level >DEBUG)        {LOG.D (tag, msg); }    }     Public Static voidV (string tag, string msg) {if(Log_level >VERBOSE)        {LOG.V (tag, msg); }    }}

(34) Log management in development (how to remove all log logs when the application is published)

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.