-1

I have a created a windows batch file(log.bat) like this below :

adb logcat -c
adb logcat -d > log.txt

But it soon exits whenever I press log.bat command.

I want it to keep recording the logs unless I press ctrl+C.

Raulp
  • 7,758
  • 20
  • 93
  • 155

3 Answers3

1

It looks problem is using option -d with logcat. Please check usage :

-d Dump the log and then exit (don't block)

Removing it will solve your problem.

Vinay Verma
  • 1,124
  • 3
  • 12
  • 18
1

From doc

-c : Clears (flushes) the entire log and exits.

-d : Dumps the log to the screen and exits.

So, in both cases, the execution stops once you run the logcat command with these options. Try this,

adb logcat -c && adb logcat > log.txt

This won't let the shell execution to be released once it executes logcat -c and will start the next command right after it which is adb logcat > log.txt that is going to write the logcat's log till you hit the Ctrl + c.

Community
  • 1
  • 1
fluffyBatman
  • 6,524
  • 3
  • 24
  • 25
  • Thanks it worked.How can I get the logs for a particular tags like D/BatteryService && E/Watchdog && V/MyAPP ..Is there any rule which I can create or additionaly put in the command you posted? – Raulp Jan 16 '17 at 05:51
  • I didn't try this out by myself but I think this will help you find what you're seeking. http://stackoverflow.com/questions/6173985/filter-output-in-logcat-by-tagname – fluffyBatman Jan 16 '17 at 05:56
0

I need to create a batch file that can copy a log file to a PC. The batch file I created doesn't work. When I run all the commands manually it works however when putting into a script it hangs. Here are the individual commands:

Try this single line command:

$adb shell run-as com.example.name cat /data/data/com.example.name/files/logfile.log > c:\logs\logfile.log
Rahul Karande
  • 259
  • 2
  • 9