Search code examples
androidtagslogcat

what does the TAG represent in Log code in android?


When do we use TAG in the log code and when do we use the string?

What does TAG represent in log codes?

For example, what are the differences between these two lines of code and How do I know when to choose which one? Log.d(TAG, "onClick: "); Log.d("string" , "onClick: ");


Solution

  • TAG is a best practice (good convention).

    after defining a TAG constant, you could use it in the subsequent log calling.

    'string' also works, but it's Hard Coding.

    See this wiki about Hard Coding