简体   繁体   中英

Android - not all logs appear in a logcat output

I am using windows cmd terminal to output logs of my application using following command:

adb.exe logcat | find "%part_of_my_apps_name%"

however, not all logs appear in the output. Only messages like this one:

I/AppService(10597): Received start id 1: Intent { cmp=package_name/.AppService(has extras) } 

And in my AppService I have the following code:

@Override
public int onStartCommand(Intent intent, int flags, int startId) {

    Log.i(TAG, "Received start id " + startId + ": " + intent);
    Log.i(TAG, "Test");

So what am I doing wrong?

UPD : I asked a bit wrong question. I actually used part of my app's name, not package, so it MUST appear in the log output.

Depending on what your TAG variable is, you use the command

adb.exe logcat -s "[tagname]"

For example if in my code, my TAG was declared as:

public static final String TAG = "com.myapp";

my LogCat would be

adb.exe logcat -s "com.myapp"

It also appears the quotes are optional.

Logcat output is not associated with the package name , but with the string TAG you are using in your code. You could change all your tags to be your package name , or you could explicitly add your package name to the message in each Log.i/w/e/v() line, and then you will get the behavior you want. However, I would actually for with @A--C suggestion instead, as it allows you to have more granular filtering of the output of specific classes only.

我使用了应用程序名称的一部分,但是,因为"find"基本上case sensitive所以它只向我显示了特定的输出(名称出现在package name中),因此我想出了以下命令:

adb.exe logcat -v time | find "%part_of_my_apps_name%" /I

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM