9

I've been told it's a command line option. But Eclipse's Run!Run Configurations...!Target!Additional Emulator Command Line Options field is already occupied with

-sdcard "C:\android-sdk-windows\tools\sd9m.img"

If I wanted to write something like

adb logcat -s MessageBox > "C:\Users\me\Documents\LogCatOutput.txt"

then where do I write it, and how (i.e., is the syntax even correct)? I need to output only a filtered tag, not verbose. ("MessageBox" is my TAG. Again I don't know if any of this punctuation is right, or even where the command goes.)

Thanks for any help.

Simon Featherstone
  • 1,716
  • 23
  • 40
user225626
  • 1,091
  • 5
  • 16
  • 32

3 Answers3

14

There should be an adb.exe file in C:\android-sdk-windows\tools. You can invoke this manually from a DOS command prompt:

cd C:\android-sdk-windows\tools
adb logcat -s MessageBox > "C:\Users\me\Documents\LogCatOutput.txt"

There's no need to bother with Eclipse in this case.

Trevor Johns
  • 15,682
  • 3
  • 55
  • 54
  • 1
    The file created in the directory is empty, blank. Both before and after I run my Android app. I don't know what to do. – user225626 Jun 30 '10 at 23:10
  • What happens if you omit the last part (> "C:\Users\me\Documents\LogCatOutput.txt"). Do you see anything? – Trevor Johns Jun 30 '10 at 23:16
  • When you run `adb logcat -s MessageBox`, you should see log messages. If not, there's something wrong with your filter spec. See this page for documentation on writing the filter spec for use with logcat: http://developer.android.com/guide/developing/tools/adb.html#logcat – Trevor Johns Jun 30 '10 at 23:40
  • See log messages in my Windows command prompt window? I mean, I can already get filtered tag LogCat pane output fine in my DDMS window. I just can't redirect to a flat file. – user225626 Jun 30 '10 at 23:50
  • Yes, that's correct. You should see log messages in your command prompt if you don't redirect to a file. If you don't see those, you're not entering the adb logcat command properly. Just trying to figure out where things are breaking down. :) – Trevor Johns Jul 01 '10 at 00:11
  • Trevor, I can't thank you enough for hanging in there with my idiocy. I run the Android app and watch the LogCat material scroll up. Then I run the Win console. Then I run the Droid app again, watch the same stuff scroll up in the LogCat tab. Run the console again. Nothing in the console, ever. – user225626 Jul 01 '10 at 00:44
  • Except if I just eliminate the MessageBox tag and run the Win console as adb logcat. Then I get verbose output inside the Win console. I just can't materialize the filter tag MessageBox--which infuriatingly works inside the Dalvik, but not in the Win console. – user225626 Jul 01 '10 at 00:51
  • Okay, so the problem is that '-s MessageBox' isn't a valid filter-spec. Try this: "adb logcat MessageBox:D *:S" – Trevor Johns Jul 01 '10 at 00:56
  • 2
    Trevor, thanks man! I've got something working here now thanks to your assistance. I'm discovering that I can run adb logcat MessageBox > "C:\Users\me\Documents\LogCatOutput.txt", i.e., without the -s flag (any flag), and I get verbose output into the flat file as the console is running. Luckily the MessageBox output is segregated contiguously inside the file output. So, great! Thanks again. – user225626 Jul 01 '10 at 01:04
  • Okay, will try that suggestion in a minute after this thing finishes. I accidentally started something on a very large input. If I can't reply on that now I will later. Again, thanks for everything. – user225626 Jul 01 '10 at 01:05
  • [Still waiting for it to finish. Went ahead and added props in the left margin.] – user225626 Jul 01 '10 at 01:11
4

Alternatively, if you only want to dump whatever's already in the logcat buffers and exit immediately (useful for scripts), you can specify the -d option:

$ adb logcat -d -s MessageBox  > dump_file.txt

Make sure that '-d' is after 'logcat'.

hopia
  • 4,880
  • 7
  • 32
  • 54
  • You don't have to do this. This option makes logcatdump the log and exit. It is useful for when you want to dump what is already logged but wont let you keep dumping to a file. – Shane Sep 30 '12 at 19:07
0

Another useful addition to the above answers is filtering. The application I am working on generates a massive amount of logging, so it is useful to log with filters.

adb -s MyDevice logcat | find /V ": T#" > d:\temp\logcat.txt

or for OSX/Linux

adb -s MyDevice logcat | grep -v ": T#" > ~/logcat.txt

This will write all logcat activity apart from any line that contains ": T#"

find or grep can also be used to filter based on positive results. I then use the likes of BareTail display the growing log file.

Simon Featherstone
  • 1,716
  • 23
  • 40