我想过滤一个logcat
String myCommand="logcat -f /sdcard/output.txt"; //no filters, keep writing
myCommand="logcat -d -f /sdcard/output.txt"; //no filters, just a dump
Run Code Online (Sandbox Code Playgroud)
对我来说工作正常但对mytag没有.
我也在使用代码:
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";
Run Code Online (Sandbox Code Playgroud)
但它返回空文件.
小智 10
try {
File filename = new File(Environment.getExternalStorageDirectory()+"/gphoto4.html");
filename.createNewFile();
String cmd = "logcat -d -f "+filename.getAbsolutePath();
Runtime.getRuntime().exec(cmd);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)
也用
String cmd = "logcat -v time -r 100 -f <filename> [TAG]:I [MyApp]:D *:S";
Runtime.getRuntime().exec(cmd);
-v -> Sets the output format for log messages.
-r -> for specifying the size of file.
-f -> file to which you want to write the logs.
[TAG] -> Tag of your application's log.
[MyApp] -> Your application name.
Run Code Online (Sandbox Code Playgroud)
File filename = new File(Environment.getExternalStorageDirectory()+"/mylog.log");
filename.createNewFile();
String cmd = "logcat -d -f"+filename.getAbsolutePath();
Runtime.getRuntime().exec(cmd);
Run Code Online (Sandbox Code Playgroud)
这个对我有用.但是对于所有logcat输出而不是特殊标签(mytag).
| 归档时间: |
|
| 查看次数: |
18252 次 |
| 最近记录: |