问题
I understand that to filter Android log messages we can use something like
adb logcat ActivityManager:I MyApp:D *:S
But, in my application, I'm using different TAGS for different activities and I want to filter all the logs of this application only. What's the best way to do it?
Do I need to specify all the tags in the command?
Or using a common tag across the application, the only other alternative?
While looking at log messages in Eclipse, I notice that there is a column named PID and another named Application (contains name of app package) both of which are (obviously) same for different Tag for a given application. That suggests that it should be possible to filter not just by Tag but by pid/package as well.
回答1:
I use a common TAG format as follows.
For Activities for example, I have defined a base Activity class...
public class MyCompanyActivity extends Activity {
protected final String TAG = this.getClass().getName();
...
}
All Activities I create extend that Activity, example.
public class FishActivity extends MyCompanyActivity {
...
}
The result is that FishActivity will have a TAG which is...
com.mycompany.myapp.FishActivity
All I then need to do is filter the logcat on com.mycompany.myapp
来源:https://stackoverflow.com/questions/9658253/filter-log-messages-by-pid-or-application-package-in-android