使用GREP命令在Android中过滤logcat [英] Using GREP command to filter logcat in Android

查看:673
本文介绍了使用GREP命令在Android中过滤logcat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  Process process = Runtime.getRuntime()。exec()使用下面的代码来读取Android中的logcat。 logcat -v time); 

由于logcat文件的大小很大,我必须过滤logcat消息。所以我使用下面的代码来过滤logcat。

  Process process = Runtime.getRuntime()。exec(logcat -v time | grep -v -E \(libloc | RPC)\); 

其中(libloc | RPC)是标签。



但是,Grep代码在Android中不起作用。任何人都可以帮助我吗?

解决方案

我得到了答案。我必须使用文件名来使用grep命令。

  Runtime.getRuntime()。exec(logcat -v time -f+ logCatFile.getAbsolutePath()+libloc:S RPC:S)


I use the following code to read the logcat in Android.

Process process = Runtime.getRuntime().exec("logcat -v time");

Since the logcat file size is large, I have to filter the logcat messages. So I used the following code to filter logcat.

Process process = Runtime.getRuntime().exec("logcat -v time | grep -v -E \"(libloc|RPC)\"");

where (libloc|RPC) are tags.

But Grep code is not working in Android. Can anyone please help me with this?

解决方案

I got the answer. I have to use the file name to use the grep command.

Runtime.getRuntime().exec("logcat -v time -f "+logCatFile.getAbsolutePath()+ " libloc:S RPC:S")

这篇关于使用GREP命令在Android中过滤logcat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆