How to filter messages to Logcat in eclipse?

こ雲淡風輕ζ 提交于 2019-12-23 20:13:00

问题


I want to show only system.out.println messages to logcat from my currently running application. I have already checked many suggestions from stack overflow and others. But all I got is suggestions like " add adb -d logcat com.example.example:I :S"... etc. But I don't know where to add this. I know how to open logcat filter settings window. It shows items named 'filter name', 'by log tag', 'by log message', 'by PID', 'by application name', and 'by log level'.
One more thing. I have added a filter with "^(?!.
(nativeGetEnabledTags)).*$" in the 'by log message' item and managed to avoid the flooding of logcat window by a message like "unexpected value from nativegetenabledtags". But the problem was, I have to add this all the time whenever I run an application(even if it is the same program) in eclipse. Is there any way to add filters for permanently?

Thanks in advance...


回答1:


I think the easiest way is to use TAG.

When you log from your android app, e.g. Log.d, the first parameter is a TAG string. So if you set it up to a unique string (like your app name) then you can later filter by it in Eclipse.




回答2:


As far as I know, Logcat is a view from Eclipse, where you see EXCLUSIVELY the messages shown thanks to the Log.d method. To check the Log messages from your app, you only have to select at the left part of the Logcat view(since the right part is where you see the Log.d messages.

If you want, it's possible to filter the Log.d messages, from your app, to see just the messages you need. For example, to see all the messages with a concrete content, you need to write down the words you want to include in the messages, at the above text box(aboce the message list). Don't forget to select previously your app on the left, otherwise you will get all the messages, from all the apps that include the text you filtered.

It's not possible to see directly a "System.out.println" on Android devices, you need to use "Log.d" method. For example:

Log.d("IOException", "IOException error");

EDIT: Here you have a picture showing what I've said to you(the app selector for Logcat)

EDIT2: To show the apps you have at your workspace, you have to go that on Eclipse:

  • Window -> Preferences -> Android -> Logcat
  • Monitor Logcat for messages from applications in workspace




回答3:


Log.I (TAG,message ) similar to system.out.println().



来源:https://stackoverflow.com/questions/14546529/how-to-filter-messages-to-logcat-in-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!