What is LogCAT?
Logcat is an excellent tool which comes with ADT. It gives you all information about what is happening in your Android Emulator or Phone if you are using an android phone for testing your applications.
Why it is Used ?
Android provides a useful logging utility class called android.util.Log. Logging messages are categorized by severity (and verbosity), with errors being the most severe.
Logcat displays filterable messages that show you what is happening in your android device. You can filter messages with verbose, warnings, errors etc. • Logcat is the place where all the errors in application will be printed, whenever you launch your application you can refer Logcat to see what is happening, in case of any error or force close application.
Below table lists some commonly used logging methods of the Log class.
Method and Purpose:
- Log.e (): Logs errors
- Log.w () : Logs warnings
- Log.i () : Logs informational messages
- Log.d () : Logs debug messages
- Log.v () :Logs verbose messages
- Log.wtf () : Logs messages for events that should not happen (like during a failed assert)
The first parameter of each Log method is a string called a tag. One common
Android programming practice is to define a global static string to represent the overall application or the specific activity within the application such that log filters can be created to limit the log output to specific data.
For example, you could define a string called TAG, as follows:
private static final String TAG = “MyApp”; Log.i(TAG, “In onCreate() callback method”);
Excessive use of the Log utility can result in decreased application performance. Debug and verbose logging should be used only for development purposes and removed before application publication.