Why use TAG in most of the Android logging code -


i can see 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 easier, if way? need not declare tag every new class.

public final class taskssample extends listactivity {     private void method() {         log.i(getclass().getname(), "message");     } }   

rather writing getclass().getname() @ each place log placed in particular activity, preferred have tag represent name of activity class.

why use tag?

when running application there might more 1 activity class in it. distinguish activity class has logged information in logcat use tag of course represents name of class.

and proper way (i not saying have written wrong) of writing tag is:

private static final string tag = taskssample.class.getsimplename(); // , not "taskssample" 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -