Q:

Why use TAG in most of the Android logging code

I can see this is common practice among Android developers.
public final class TasksSample extends ListActivity {
    private static final String TAG = "TasksSample";
    private void method() {
        Log.i(TAG, "message");
    }
}

Will it be easier, if I do it this way? I need not to declare TAG for every new class.
public final class TasksSample extends ListActivity {
    private void method() {
        Log.i(getClass().getName(), "message");
    }
}  

A:

Rather than writing getClass().getName() at each place where a log is placed in a particular activity, it is always preferred to have a TAG that would represent the name of the activity class.
Why use TAG?
When you are running your application there might be more than one Activity class in it. To distinguish which activity class has logged the information in logcat we use a TAG which of course represents the name of the class.
And the proper way (I am not saying what you have written is wrong) of writing the TAG is:
private static final String TAG = TasksSample.class.getSimpleName(); // and not "TasksSample"

A:

Every previous answer is right, but I just wanna add a little comment.
private static final String TAG = TasksSample.class.getSimpleName();

or
private static final String TAG = "TasksSample"

The latter is used when you use proguard. As you know, proguard obfuscates class names and it affects logs too.

