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

前端 未结 3 2149
说谎
说谎 2021-02-01 18:53

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

3条回答
  •  清歌不尽
    2021-02-01 19:31

    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.

提交回复
热议问题