adb logcat -f log.txt error: couldn't open output file: Read-only file system

元气小坏坏 提交于 2019-12-03 11:02:21

问题


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.

According to the logcat command line instructions this should be trivial with

logcat -f logfile.txt

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

but this always responds with

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

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.

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

Any suggestions?


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.


回答1:


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

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'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.




回答2:


adb logcat > logfile.txt

adb logcat *:E > logfile.txt

If you want only errors filtered.

This works for me on MS Windows 7.




回答3:


Use adb logcat -d > log.txt

This will write the logs on to your development machine.



来源:https://stackoverflow.com/questions/23425066/adb-logcat-f-log-txt-error-couldnt-open-output-file-read-only-file-system

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