Android adb logcat -f log.txt 错误:无法打开输出文件:只读文件系统
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23425066/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
adb logcat -f log.txt error: couldn't open output file: Read-only file system
提问by Cheeseminer
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.
在 Windows (win7) 上,通过 USB 调试真正的手机我想将 logcat 日志转储到我的 PC 上的文件中。数据速率超出了eclipse中可用的速率;我想要整个未过滤的日志。
According to the logcat command line instructionsthis should be trivial with
根据logcat 命令行说明,这应该很简单
logcat -f logfile.txt
logcat -f logfile.txt
I'm using adb logcat -f logfile.txt
on the windows command line
我adb logcat -f logfile.txt
在 windows 命令行上使用
but this always responds with
但这总是回应
couldn't open output file: Read-only file system
couldn't open output file: Read-only file system
The file system is notread-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.
文件系统不是只读的。在那里创建和写入文件工作正常,并且粗略的重定向(例如)adb logcat > logfile.txt
也按预期工作。提供日志文件的完整路径没有任何区别。
I'd like to make use of logcat's -n
and -r
options but they require -f
to work.
我想使用 logcat-n
和-r
选项,但它们需要-f
工作。
Any suggestions?
有什么建议?
Notes.
This question is close to one asked on Ubuntubut 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.
笔记。这个问题与在 Ubuntu 上提出的问题很接近,但在 Windows 上没有对我有用的答案,还有一个我已经尝试过但不起作用的建议。SO 上的大多数类似参考都只是引用了帮助页面,说-f filename
应该有效。
Question edited to keep it up to date with useful comments & responses.
已编辑问题以使其与有用的评论和回复保持同步。
回答by Chris Stratton
Unfortunately, the -f
option to logcat
appears to be only able to create files on the file system of the android deviceand not on the development host.
不幸的是,该-f
选项logcat
似乎只能在android 设备的文件系统上创建文件,而不能在开发主机上创建文件。
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
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.
作为进一步的解释,实验表明键入adb logcat
会导致/system/bin/logcat
设备上的程序被执行,类似于键入adb shell logcat
. ADB 可以简单地将此程序的标准或错误输出传递回主机,但没有设备端 API,设备上运行的程序可以使用它来要求 ADB 在开发机器上创建文件。在开发机器上运行的 ADB 部分中实现保存到文件和旋转操作是可能的,但这不是它目前的工作方式。
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.
bonitarunner 在开发机器上使用 shell 重定向的解决方案是一个简单的答案。应该可以提出一个主机端过滤程序或脚本,它可以实现类似于-r
和-n
选项的限制和旋转功能。
回答by bonitarunner
adb logcat > logfile.txt
adb logcat *:E > logfile.txt
If you want only errors filtered.
如果您只想过滤错误。
This works for me on MS Windows 7.
这在 MS Windows 7 上对我有用。
回答by flameshimmer
Use adb logcat -d > log.txt
用 adb logcat -d > log.txt
This will write the logs on to your development machine.
这会将日志写入您的开发机器。