亚行logcat - f日志。txt错误:不能打开输出文件:只读文件系统。

时间:2021-05-08 14:01:44

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文件放到我电脑上的一个文件中。数据的速率超出了eclipse的可用性;我想要整个未过滤的日志。

According to the logcat command line instructions this 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。在windows命令行上的txt。

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.

文件系统不是只读的。在那里创建和写入文件是可行的,而且还会有一个粗糙的重定向,比如adb logcat >日志文件。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 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.

笔记。这个问题与Ubuntu的问题很接近,但是在Windows上没有答案,而且我已经尝试过了,但没有成功。大多数类似的引用都引用了帮助页,说-f文件名应该起作用。

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

编辑的问题,以使它最新的有用的评论和回应。

3 个解决方案

#1


28  

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.

不幸的是,logcat的-f选项似乎只能在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会使设备上的/系统/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选项的限制和旋转功能。

#2


19  

adb logcat > logfile.txt

adb logcat *:E > logfile.txt

If you want only errors filtered.

如果您只希望过滤错误。

This works for me on MS Windows 7.

这在Windows 7上为我工作。

#3


15  

Use adb logcat -d > log.txt

使用adb logcat -d > log.txt。

This will write the logs on to your development machine.

这将把日志写到您的开发机器上。

#1


28  

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.

不幸的是,logcat的-f选项似乎只能在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会使设备上的/系统/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选项的限制和旋转功能。

#2


19  

adb logcat > logfile.txt

adb logcat *:E > logfile.txt

If you want only errors filtered.

如果您只希望过滤错误。

This works for me on MS Windows 7.

这在Windows 7上为我工作。

#3


15  

Use adb logcat -d > log.txt

使用adb logcat -d > log.txt。

This will write the logs on to your development machine.

这将把日志写到您的开发机器上。