NullPointerException
NullPointerException

Reputation: 489

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.

Upvotes: 0

Views: 1228

Answers (3)

NullPointerException
NullPointerException

Reputation: 489

I used a part of app's name, however, because "find" is basically case sensitive it did show me only that particular output ( name appeared in package name ) , so I came up with the following command:

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

Upvotes: 0

A--C
A--C

Reputation: 36449

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.

Upvotes: 1

Franci Penov
Franci Penov

Reputation: 76021

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.

Upvotes: 0

Related Questions