I assume most of you are aware of android.util.Log All logging methods accept 'String tag' as a first argument.
And my question is How do you usually tag your logs in your applications? I've seen some hardcode like this:
public class MyActivity extends Activity { private static final String TAG = "MyActivity"; //... public void method () { //... Log.d(TAG, "Some logging"); } }
This doesn't look nice because of many reasons:
Is there any neat way to get a TAG for a class?
Every Android log message has a tag and a priority associated with it. The tag of a system log message is a short string indicating the system component from which the message originates (for example, ActivityManager ).
To access the logging output, run the 'adb' executable with following arguments to capture the Android Enterprise related logging: Windows: C:\Users\[username]\AppData\Local\Android\sdk\platform-tools> adb logcat -G 32M; adb shell setprop persist. log. tag.
I use a TAG, but I initialise it like this:
private static final String TAG = MyActivity.class.getName();
This way when I refactor my code the tag will also change accordingly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With