Search this blog

How to log android application information

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. Below see some commonly used logging methods of the Log class.

Method               Purpose

Log.e()                 Logs errors
Log.w()                Logs warnings
Log.i()                  Logs informational messages
Log.d()                 Logs debug messages
Log.v()                 Logs verbose messages

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”;
Now anytime you use a Log method, you supply this tag. An informational logging
message might look like this:
Log.i(TAG, “In onCreate() callback method”);


Post a Comment