Android Learning 7--use of log information

Source: Internet
Author: User

In the code debugging, the log information is essential, about the use of log information, next, a brief description of the small:

There are several types of logs: Verbose: Literally, Verbose is verbose, verbose, so the content of Verbose log information output is more comprehensive

Debug log information

Info log Information

Warn log information

Error log information

Assert log information

There are many kinds of output of the log, first of all, the use of log output logs, the code is as follows:

public class LogTestDemo1 extends Androidtestcase {
private static String Loginfo = "Loginfo";
private static String Logdebug = "Logdebug";
private static String logwarning = "logwarning";
private static String LOGERROR = "LOGERROR";
private static String Logverbose = "Logverbose";
private static String LOGWTF = "LOGWTF";

public void Test1 () throws exception{
LOG.I (Loginfo, "This is a Info log"); Output Info Log information
LOG.D (Logdebug, "This is a Debug log"); Output Debug Log information
LOG.E (LOGERROR, "This is a Error log"); Output error log information
LOG.V (Logverbose, "This is a Verbose log"); Output verbose log information
LOG.W (logwarning, "This is a Warning log"); Output warning information
LOG.WTF (LOGWTF, "What's a teriable log");//Output A What a terrible failure log information
}
}

After running this test code, the following is shown in Logcat:

The second output log information is in the form: using the System.out output:

System.out.println ("This is a Log test");

Shown in Logcat as:

The default is info level, labeled System.out

The third type: using System.err output

System.err.println ("This is a Log test");

Shown in Logcat as:

The default is warn level, labeled System.err

There are three ways to output log information, but the first is the recommended way to use 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.