Reputation: 65
I am trying the following code to get if condition on adb logcat:-
Search for the Exception or ANR (Activity Not Responding) on com.testapp.demo package If any Exception or ANR is found it will save the logs into the destination folder
if adb logcat | grep 'Exception*'
then
adb logcat -d > $SILENT_EXCEPTION_FILE
fi
but I am not able to save it. Somehow this command does not work.
Upvotes: 1
Views: 333
Reputation: 11
adb logcat
outputs the logs as they arrive and never exits, so adb logcat | grep
never exits either. adb logcat -d
should be used if you want to read the current logs.
Upvotes: 1
Reputation: 4197
I'd suggest using the following:
adb logcat | grep --line-buffered 'Exception*' > $SILENT_EXCEPTION_FILE
Upvotes: 0