Why use TAG in most of the Android logging code
android
Solution
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"
Problem
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"); } } ```