adb logcat 保存,adb logcat -f log.txt错误:无法打开输出文件:只读文件系统

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.

解决方案

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值