What is LogCat in Eclipse?

前端 未结 9 1644
余生分开走
余生分开走 2020-12-07 01:04

What does LogCat do in Eclipse?

How do I use it? I have never used the log cat before in Eclipse, so I don\'t understand.

相关标签:
9条回答
  • 2020-12-07 01:39

    When you run your applications in debug you can have details on why they are crashing, plus if you want to write in it you can :

    Log.i(String tag, String msg);
    
    0 讨论(0)
  • 2020-12-07 01:39

    You use LogCat by adding commands like this in your code:

    Log.d(TAG, stringVar);

    The TAG is a string constant that will help filter the output from LogCat. The TAG may be the name of your Activity or Application. You use the filter in the LogCat window to see only the filtered output.

    String TAG = "AppName";

    The stringVar can contain anything that may be helpful for your understanding of how the code works when you need to debug it,

    An example is if you are unsure of the value of an int variable (f.ex. intVal): --- code --

    String stringVar = " value of integer intVal = " + new Integer( intVal ).toString(); Log.d(TAG, stringVar); --- code end ---

    LogCat is very useful. You can add the LogCat window in Eclipse by doing this "Window -> Show View -> Other -> Android -> Logcat"

    0 讨论(0)
  • 2020-12-07 01:41

    LogCat is an Android feature that allows you viewing logs emitted by the applications running on an Android device.

    When you are running your application in debugging mode from Eclipse, you can see plenty of logs appearing in this window: those of your own application, but also those posted by the system and other applications running at the same time on this device.

    To log something, you have first to determine how your message is critical (is this debuggin info, an informational message, a warning or an actual error message?) and then use the appropriate method:

    Log.d("myApp", "my debug message");  
    Log.i("myApp", "my informational message");
    Log.w("myApp", "my warning message");
    Log.e("myApp", "my error message");
    
    0 讨论(0)
提交回复
热议问题