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

3

28

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.

Diedra answered 2/5, 2014 at 9:39 Comment(0)
E
40

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.

Ersatz answered 7/5, 2014 at 14:58 Comment(0)
H
32

Use adb logcat -d > log.txt

This will write the logs on to your development machine.

Heartstrings answered 29/1, 2015 at 3:55 Comment(1)
good call, was looking all over for the -d option and missed it in the reference docs. in case anyone else is wondering, it causes adb to write the output and stop listening for logcat messages, rather than leaving the prompt "hanging".Zingale
B
23
adb logcat > logfile.txt

adb logcat *:E > logfile.txt

If you want only errors filtered.

This works for me on MS Windows 7.

Borehole answered 5/5, 2014 at 18:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.