How to filter only my application log in IntelliJ's logcat? [duplicate]

五迷三道 提交于 2019-12-04 16:16:43

问题


On IntelliJ, i'm trying to read the logcat for seeking errors.

The problem is that all the applications' log are present in the 'Android' Window.

How to only display the log that is relevant ?

I'm not looking for tags since i want to view Exception throws, Segfaults from JNI, etc.

Thanks !


回答1:


You can filter by the process ID (PID):

The only drawback is that PID changes and you will have to adjust the filter after every app restart.




回答2:


Filtering based on an application (package) is not available in IntelliJ IDEA (current version: 12).




回答3:


EDIT: Everything above the horizontal rule is my new answer (updated 5/17/13):

I'd suggest moving over to the new Android Studio IDE (which is based of IntelliJ). This allows filtering by package name.


You can vote for the feature to be added here: http://youtrack.jetbrains.com/issue/IDEA-95780

In the meantime, you may think about wrapping the Android Log class to add a suffix/prefix that you could then filter by. Something like the following:

/**
 * Wrapper for the Android {@link Log} class.
 * <br><br>
 * The primary reason for doing this is to add a unique prefix to all tags for easier filtering
 * in IntelliJ IDEA (since in v12 there is no way to filter by application).
 *
 * @author gloesch
 */
public class Logger {

    private static final String FILTER = "(MY APP) ";

    public static void d(String tag, String message) {
        Log.d(tag.concat(FILTER), message);
    }

    public static void i(String tag, String message) {
        Log.i(tag.concat(FILTER), message);
    }

    public static void v(String tag, String message) {
        Log.v(tag.concat(FILTER), message);
    }

    public static void e(String tag, String message) {
        Log.e(tag.concat(FILTER), message);
    }

    public static void w(String tag, String message) {
        Log.w(tag.concat(FILTER), message);
    }

    public static void wtf(String tag, String message) {
        Log.wtf(tag.concat(FILTER), message);
    }
}



回答4:


Depends on what you're trying to do. In the logcat window, you should have an [non]empty window named "Filters" with a + or - next to it (as it appears in IntelliJ IDEA 12) and it'll pop up a window like this:

If the Log Tag isn't what you need, you can filter based on a regexp in the log message itself (e.g. if the message always starts with seek error, then input seek and it should find it. If you set Log Level to Verbose it should match anything that gets written to logcat.



来源:https://stackoverflow.com/questions/12436400/how-to-filter-only-my-application-log-in-intellijs-logcat

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