且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从的logcat到SD卡我的日志输出重定向在Android设备上?

更新时间:2023-09-28 08:10:22

使用 logcat的-f<文件名> ,以将其转储到文件系统中的文件。
请确保您使用的文件名是在SD卡,即始于 / SD卡/...

use logcat -f <filename> in order to dump it to a file in the filesystem.
Make sure the filename you're using is in the sdcard, i.e. starts with /sdcard/....

此外,为了参数传递给的logcat 程序,你应该通过 EXEC 方法数组字符串(而不是一个字符串):

Also, in order to pass arguments to the logcat program, you should pass the exec method an array of strings (and not one string):

String[] cmd = new String[] { "logcat", "-f", "/sdcard/myfilename", "-v", "time", "ActivityManager:W", "myapp:D" };

最后,如果一切都失败了,使用的logcat的完整路径: /系统/斌/ logcat的,而不是仅仅的logcat