new Thread(new Runnable() { @Override public void run() { File logFile = new File("/sdcard/logcat.txt"); if(logFile.exists()) logFile.delete(); try { Process process = Runtime.getRuntime().exec("logcat -c"); // process = Runtime.getRuntime().exec("logcat -f " + logFile + " *:S MainActivity:D MyActivity2:D"); process = Runtime.getRuntime().exec("logcat -f " + logFile); } catch (IOException e) { e.printStackTrace(); } } }).start(); From:
logcat -f /sdcard/log.log -v time -s tag