user533844
user533844

Reputation: 2063

Android logcat command

I want to get "last 25 logs of tag name CordovaLog" I tried

logcat -t 25 CordovaLog

I do get 25 logs but of all the tag names. Also what if there are no 25 Cordova Log ? Will it return whatever is available.

So what is the right command ? Thanks.

EDIT 1-

        Process process = Runtime.getRuntime().exec("logcat -d -t 25 CordovaLog:V *:S"); 
        BufferedReader bufferedReader = new BufferedReader( new InputStreamReader(process.getInputStream())); 
        StringBuilder log = new StringBuilder(); 
        String line;
        while ((line = bufferedReader.readLine()) != null)  
        { 
                log.append(line+"<br />");
        } 
        return log.toString();

So Is this code getting all the logs are filting to get "Cordova logs" ? OR it's just getting "Cordova logs" ? It's crashing as I have lots of logs.

Upvotes: 1

Views: 2118

Answers (1)

AitorTheRed
AitorTheRed

Reputation: 553

the correct use will be

logcat -d -t 25 CordovaLog:V *:S

With this, you will print all that have the tag CordovaLog, and will silent everything else.
You can have more information in the official documentation.

Edite to fix the correct answer (see comment below). It will print the last 25 entries, or less in case there are less than 25 entries.

Upvotes: 2

Related Questions