Use of Android log cat
Android provides us with a log class, which has some methods such as
We can add these methods to our code to test
1 Packagecom.example.test;2 3 Importandroid.app.Activity;4 ImportAndroid.os.Bundle;5 ImportAndroid.util.Log;6 ImportAndroid.view.Menu;7 ImportAndroid.view.MenuItem;8 9 Ten Public classMainactivityextendsActivity { One Private FinalString tag = "Mainactivity"; A @Override - protected voidonCreate (Bundle savedinstancestate) { - Super. OnCreate (savedinstancestate); the Setcontentview (r.layout.activity_main); - - //System.out.println (1/0); - +LOG.V (Tag, "I'm V"); -LOG.D (Tag, "I'm D"); +LOG.I (tag, "I Am I"); ALOG.W (tag, "I am w"); atLOG.E (Tag, "I'm E"); -System.out.println ("hehe"); - } $}
Let's take a look at the information we get from the log cat.
We can see the error message by the level of the log, generally look at the error level or the Warn level basically know where the error occurred, but you can also test the error by creating a log filter
That is, the small green plus sign on the top, when clicked, pops up a dialog box, such as
When we look at the error message, we can click on the red box and select it to view it.
Use of Android log cat