to filter logcat only from your application, try the following:
int pid = android.os.Process.myPid(); File outputFile = new File(Environment.getExternalStorageDirectory() + "/logcat.txt"); Log.d("zzz","outputFile: " + outputFile); try { String command = "logcat | grep " + pid + " > " + outputFile.getAbsolutePath(); Log.d("zzz","command: " + command); Process p = Runtime.getRuntime().exec("su"); OutputStream os = p.getOutputStream(); os.write((command + "\n").getBytes("ASCII")); } catch (IOException e) { }
source share