How to redirect my log output from logcat to the SD-Card on an android device?
android, logging
Solution
use `logcat -f <filename>` in order to dump it to a file in the filesystem. Make sure the filename you're using is in the sdcard, i.e. starts with `/sdcard/...`.
Also, in order to pass arguments to the `logcat` program, you should pass the `exec` method an array of strings (and not one string):
String[] cmd = new String[] { "logcat", "-f", "/sdcard/myfilename", "-v", "time", "ActivityManager:W", "myapp:D" };
Finally, if all else fails, use the full path for logcat: `/system/bin/logcat` instead of just `logcat`.
Problem
I'm trying to redirect the log of my app to the sdcard file. But i failed to do so. I'm trying something like this. ``` String cmd= "logcat -v time ActivityManager:W myapp:D *:* >\""+file.getAbsolutePath()+"\""; Runtime.getRuntime().exec(cmd); ``` I tried the -f option also but it is not working either.