0

i want to redirect the Android developer tools logcat output to a file into the virtual device from a shell command, before than running the android app test. The command i usually use to redirect the output to a file is:

adb shell logcat -v time - f log.txt packageName:F *:E > /folder/log.txt

but it puts the log file into a computer directory (/folder/ in this case). I want to change it with a directory in the virtual device but like above, it says the folder does not exist. There is way to do it via shell command?

2 Answers 2

2

You can simply do

adb shell "logcat -v time -f /mnt/sdcard/log.txt packageName:F *:E"

to accomplish it all in one command from the host shell. You do not need the redirect when you use the -f flag, in fact the redirect would not capture anything if you have directed the output of logcat to a file rather than to stdout.

If that is not working, it is either because you are using a version of Android which mounts the external storage at some other path, or you do not have an emulated sdcard attached to your virtual device.

You can investigate either of these problems by examining the output of

adb shell mount

If you do not have an sdcard at all on your AVD, follow the emulator documentation instructions for creating and attaching one.

For testing purposes only there may be other paths than the sdcard at which you can write, particularly on an emulator where the adb shell runs as root, for example on some versions /data/local or similar.

0

You can try this one adb shell then #logcat>/sdcard/log.txt now i am sure about the results.you just need a command prompt window to be opened for adb shell,that's not so bad i guess.

4
  • is the same than mine, with the only difference that filter the output at a particular level. the folder /sdcard/log.txt does not exist
    – idell
    Commented Dec 6, 2013 at 13:16
  • does not work: adb does not signal any error but in the path specified (/sdcard/) there are no log.txt.
    – idell
    Commented Dec 6, 2013 at 15:28
  • well,it is working for me.check if your emulator has an sdcard or not
    – insomniac
    Commented Dec 7, 2013 at 3:40
  • now works, probably 'cause before i had some java logger redirected to another file and i cannot redirect same outputs to different files.
    – idell
    Commented Dec 7, 2013 at 10:41

Not the answer you're looking for? Browse other questions tagged or ask your own question.