我想以编程方式获取logcat数据,我使用下面的代码
StringBuilder debuglog=new StringBuilder();
try {
Process process = Runtime.getRuntime().exec("logcat -d");
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
while ((line = bufferedReader.readLine()) != null) {
debuglog.append(line);
debuglog.append("\r\n");
}
} catch (IOException e) {
e.printStackTrace();
}
以上代码工作正常
此行"logcat -d
“显示-d,-w,-i messages
但是,我的问题是我想要显示-e消息
答案 0 :(得分:4)
要获得ERROR,请使用此选项:
Process process = Runtime.getRuntime().exec("logcat -d *:E");