本文介绍了adb logcat -f log.txt错误:无法打开输出文件:只读文件系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows(win7)上,通过USB调试真实电话我想将logcat日志转储到PC上的文件中.数据速率超出了日蚀可用的范围;我想要整个未过滤的日志.

On windows (win7), debugging a real phone via USB I want to dump the logcat log into a file on my PC. The rate of data is beyond what is usable in eclipse; and I want the whole unfiltered log.

根据 logcat命令行说明,与

logcat -f logfile.txt

我在Windows命令行上使用adb logcat -f logfile.txt

I'm using adb logcat -f logfile.txt on the windows command line

但这总是以

couldn't open output file: Read-only file system

文件系统不是 只读.在此处创建和写入文件可以很好地工作,并且像adb logcat > logfile.txt这样的粗略重定向也可以按预期工作.提供日志文件的完整路径没有区别.

The file system is not read-only. Creating and writing files there works fine, and a crude redirection such as adb logcat > logfile.txt also works as expected. Providing the whole path to the log file makes no difference.

我想使用logcat的-n-r选项,但是它们需要-f才能工作.

I'd like to make use of logcat's -n and -r options but they require -f to work.

有什么建议吗?

注意.这个问题与在Ubuntu上问到的问题接近,但是在Windows上没有对我有用的答案,还有一个建议我已经尝试过并且不起作用. SO上大多数类似的参考文献只是引用帮助页面,说-f filename应该有效.

Notes.This question is close to one asked on Ubuntu but that has no answers that are useful to me on Windows, and one suggestion that I've already tried and doesn't work. Most similar references on SO simply quote the help page, saying -f filename should work.

已对问题进行了修改,以使其包含有用的评论和最新信息.回应.

Question edited to keep it up to date with useful comments & responses.

推荐答案

不幸的是,logcat-f选项似乎只能在 android设备的文件系统上创建文件,而不是在开发主机上.

Unfortunately, the -f option to logcat appears to be only able to create files on the file system of the android device and not on the development host.

通过指定裸文件名,最有可能导致它尝试在设备的根目录中创建一个通常不可写的文件.

By specifying a bare filename, you were most likely causing it to try to create a file in the device's root directory, which is not normally writeable.

如果您希望在设备上创建文件,请指定一个可写位置(适当的路径因设备和构建而异,但以当前示例为例):

If you wish to create a file on the device, then specify a writable location (appropriate paths will vary by device and build, but to take a current example):

adb logcat -f /mnt/sdcard/log.txt

通过进一步的解释,实验表明,键入adb logcat会导致设备上的/system/bin/logcat程序被执行,这与键入adb shell logcat时的情况类似. ADB可以将标准或错误输出从该程序简单地传递回主机,但设备上运行的程序无法使用设备侧API来要求ADB在开发计算机上创建文件.保存到文件和循环操作可能会在开发计算机上运行的ADB部分中实现,但这不是目前的工作方式.

By way of further explanation, experiment shows that typing adb logcat causes the /system/bin/logcat program on the device to be executed, similarly to what happens if you type adb shell logcat. ADB can trivially pass the standard or error output from this program back to the host machine, but there is no device-side API which a program running on the device could use to ask ADB to create files on the development machine. It would be possible for the save-to-file and rotation operations to be implemented in the portion of ADB which runs on the development machine, but that is not how it presently works.

bonitarunner解决方案是一个简单的答案.应该有可能提出一个主机端筛选程序或脚本,该程序或脚本将实现类似于-r-n选项的限制和循环功能.

bonitarunner's solution using a shell redirect on the development machine is a simple answer. It should be possible to come up with a host-side filter program or script which would implement limiting and rotation functionality similar to the -r and -n options.

这篇关于adb logcat -f log.txt错误:无法打开输出文件:只读文件系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 00:37