2

I used to use the the GUI version of logcat via DDMS for getting Adb logcat info from Android Studio (or monitor.exe from SDK tools), but found it too distracting while trying to test.

I would have to quickly stop testing, then copy and save the data from DDMS to a file when I find a bug or when the would app crash on my Android Phone or Tablet.

I am not familiar with the adb command line so any detailed help (or some links to syntax and scenario based examples) would be very much appreciate.

I found and created a script file for windows with the following command:

"C:\Users\dare2\AppData\Local\Android\sdk\platform-tools\adb.exe" logcat -d > "%UserProfile%\Desktop\%date:~-4,4%%date:~-10,2%%date:~-7,2%_%..."

This creates a file with the current date and outputs the logcat data to that file on my desktop. As I understand it though (and correct me if I am wrong), but it just dumps the data already cached on my device at the time I run the command. What I want to do is:

  • Clear the cached log data at the initiation of the script

  • Continuously stream the logcat data to the file as I am testing apps while connected via USB.

  • Append a start and end timestamp to the filename

  • End the output some way when done with whatever task I am testing (don't care if the method is just disconnecting from the USB cable)

  • Be able to click on the script again and have it do the steps above to another file (which would resolve itself cause timestamps would be different)

Currently it just creates the one file with the date, which I have to rename, then start over for each test I perform (Exploratory/Functional).

So for example:

One Scenario for me would be to testing the entire installation process of an app, including the first run (capturing any on-boarding process or registration process data that the app requires) and then stop either if/when the app crashes or when I get to the first instance of the main activity screen in the android app (my choice).

Another Scenario would be for example running a section of a scripted functional or regression test, lets say 10 step. Before I start, Run the script, which would perform the steps indicated above, then stop once I am done running that section of the test case or if/when the app crashes.

Thank You

4
adb logcat -v long time > C:\Users\username\folder\logcat.log 
0

The command you want to continuously stream is just:

"logcat > {somefile.txt}"
logcat -c should clear before starting.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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