Saving Logcat Output to File

I've searched and found many solutions on this, but they all keep the Verbose level. , not just the debug or error level

I would like to keep only the debug layer.

//currently the command i am using is this: 

 String[] cmd = new String[]{"logcat", "-f", filepath, "-v", "time"};

//i think it should be something like this 
 String[] cmd = new String[]{"logcat", "-f", filepath, "-v", "time", "-v" ,"tag: D/"};

      

+3


source to share


1 answer


here is the commande line i used in my application, you just need to put "packagename: debugLevel"

LOGCATCOMMANDE = new String[] { "logcat", "-f", logFile1.getAbsolutePath(), "-r", Integer.toString(SizeOfLogFile), "-n", Integer.toString(numberOfFileRrotation), "-v", "long", "ActivityManager:W", "PACKAGENAMEHERE:D"};
        process = Runtime.getRuntime().exec(LOGCATCOMMANDE);

      

Hope this helps, I've spent quite a bit of time trying to find a solution in the past ^^ '



EDIT:

As mentioned in another answer, don't forget the permission:

<uses-permission android:name="android.permission.READ_LOGS" />

      

+2


source







All Articles