Logcat Output from Android

Source: Internet
Author: User

Android Logcat is a very convenient debugging tool, but the output of log is divided into several, in later learning will use the log, today in-depth understanding:

??

In Android, verbose and debug messages are displayed while the program is being debugged; information, warn, error, and assert are displayed in both debug and release versions of the application;

The class Android.util.Log contains several static methods that output log information at an incremental level, respectively, ERROR,? WARN, INFO, DEBUG, VERBOSE

If the application is developed for the actual device, then debug and verbose are not included in the compiled application;

Afraid to mislead everyone, direct API:

??

The following is an introduction to the log, according to someone else's blog about log, feel well written, quoted part, and made some changes, as follows:

android.util.log commonly used methods have the following 5 : log.v (), LOG.W () and? log.e () VERBOSE, debug< Span style= "font-size:10pt", info, , error

1. log.v () the output color is black, any message will be output, here V for verbose meaning, usually used is LOG.V ("", "");

2. the output color of log.d () is blue, only the meaning of debug debug is output, in addition to output I, W, E, filter up can be selected by Ddms Logcat label.

3. the output color of log.i () is green, the general informational message information, which does not output LOG.V and log.d information, but displays information about I, W, and E

4. the output color of LOG.W () is orange and can be seen as a warning warning, which generally requires our attention to optimize the Android code, while selecting it will also output LOG.E information.

5. log.e () The output color is red, you can think of error errors, here only the red error message, these errors need our careful analysis, view the stack of information.

??

Here's my own program to test the output of log:

Interface:

Source:

XML code:

<TextView

Android:layout_width="wrap_content"

Android:layout_height="wrap_content"

Android:layout_centerinparent="true"

Android:text="Log output Test " />

??

<Button

Android:layout_width="fill_parent"

Android:layout_height="wrap_content"

Android:layout_alignparentbottom="true"

Android:onclick="Onoutlog"

Android:text=" Click Output Log " />

Public class mainactivity extends actionbaractivity {

??

Activity code :?

@Override

protected void onCreate (Bundle savedinstancestate) {

Super . OnCreate (savedinstancestate);

Setcontentview (r.layout. Activity_main );

}

Public void onoutlog (view view) {

Log. v ("LogOut","LOG.V () output to VERBOSE");

Log. D ("LogOut","LOG.D () output to DEBUG");

Log. I ("LogOut","log.i () output to INFO");

Log. W ("LogOut","LOG.W () output to WARN");

Log. e ("LogOut","LOG.E () output to ERROR");

}

}

??

Here's the experiment.

The following is the output in the verbose view:

??

The following is the output in the Debug view:

??

The following is the output in the info view:

??

The following is the output under the Warn view:

??

The following is the output under the error view:

??

??

My current summary is not deep enough, just know, using a different log output function, their level is different, the corresponding will also be displayed in various views, and so on to understand more thoroughly, then to do more in-depth test and summary it

??

??

??

??

??

??

??

??

Logcat Output from Android

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.