Amit_android Amit_android - 7 months ago 69
Android Question

Catch LogCat programmatically or export it to file?

I want to filter a logcat

String myCommand="logcat -f /sdcard/output.txt"; //no filters, keep writing
myCommand="logcat -d -f /sdcard/output.txt"; //no filters, just a dump

Working fine for me but not for mytag .

I am also using the code:

String myCommand="logcat myTag *:S"; //the equivalent of logcat -s myTag
myCommand="logcat -s myTag:D";
myCommand="logcat -s myTag:E myTag2:D";
myCommand="logcat myTag:E myTag2:D";

But it returns empty file.

File filename = new File(Environment.getExternalStorageDirectory()+"/mylog.log"); 
String cmd = "logcat -d -f"+filename.getAbsolutePath();

it works for me. but for all logcat output not for special tag(mytag).