How to use the logging tool in Android
This article mainly introduces the relevant knowledge of "how to use the log tool in Android". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to use the log tool in Android" can help you solve the problem.
Use Android's logging tool Log
Methods:
The logging utility class in Android is Log, which provides the following methods for us to print logs:
How to use it:
Log.d ("MainActivity", "onCreate execute")
The second parameter: msg, the specific content you want to print.
Such as:
Public class MainActivity extends AppCompatActivity {protected void onCreate (Bundle savedInstanceState) {super.onCreate (savedInstanceState); setContentView (R.layout.activity_main); Log.d ("MainActivity", "onCreate execute");}}
Use TAG techniques:
It is unwise to enter Tag manually every time. We can define a constant to facilitate the next input:
Public static final String TAG = "MainActivity";.... Log.d (TAG, "onCreate execute")
Why use Log instead of System.out
1. Log printing is uncontrollable
two。 The print time cannot be determined.
3. Cannot add filter
4. There is no level distinction between logs.
This is the end of the introduction on "how to use the logging tool in Android". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.