Simple use of Java's Logcat

Source: Internet
Author: User

Android.util.Log commonly used methods include the following 5 :log.v () log.d ( ) log.i () LOG.W () and log.e () . According to the first letter corresponds to VERBOSE,debug,info, Warn,error.

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

2, LOG.D output color is blue , only the meaning of debug debugging output, but he will output the upper level of information, filtering up can be DDMS by the logcat tag to choose.

3, LOG.I output is green , general informational message information, it will not output LOG.V and LOG.D information, but will display I, W and e information

4, log.w the meaning of Orange , can be seen as a warning warning, we generally need to pay attention to optimize the Android code, while selecting it will also output LOG.E information.

5, LOG.E 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.

Note: Different printing methods are used with a method (string tag, string msg) parameter, tag is the label of the printed information, and MSG is the information that needs to be printed.

Package Com.example.demo;  Import Android.os.Bundle;  Import android.app.Activity;  Import Android.view.Menu;  Import Android.util.Log;  public class Mainactivity extends Activity {  final static String tag= "LOGCAT";  @Override  protected void onCreate (Bundle savedinstancestate) {  super.oncreate (savedinstancestate);  Setcontentview (r.layout.activity_main);  LOG.V (TAG, "verbose");  LOG.D (TAG, "Debug");  LOG.I (TAG, "Info");  LOG.W (TAG, "Warn");  LOG.E (TAG, "Error");  }  @Override Public  Boolean oncreateoptionsmenu (Menu menu) {  //Inflate the menu, this adds items to the action Bar If it is present.  Getmenuinflater (). Inflate (R.menu.main, menu);  return true;  }  }  

  

Simple use of Java's Logcat

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.