How to print the logcat log to cmd prompt

纵饮孤独 提交于 2019-12-12 04:38:34

问题


I'm running scenarios in UIAutomator.My output is displayed in CMD prompt. Whenever there is a failure i'm printing strings (displayed in Cmd prompt). When the scenarios fails, Is it possible to print the log snippet from logcat logs to cmd prompt?


回答1:


Late Answer, but better late than never ;-)

You can construct a BufferedReader that reads from logcat like this:

  BufferedReader bufferedReader = new BufferedReader(
                new InputStreamReader(Runtime.getRuntime().exec("logcat -d").getInputStream()));

and then continue using BufferedReader for getting the text content as usual and print for example to Cmd prompt as you wanted. Not sure if that is the best practice doing it this way, but it works.



来源:https://stackoverflow.com/questions/20801597/how-to-print-the-logcat-log-to-cmd-prompt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!