How to Remove All Log Files from a Device using API

Modified on Sun, Jun 14 at 3:08 PM

Overview

This API allows users to remove all log files from a specified device by executing an ADB shell command. It is commonly used to clean up application logs before or after test execution, ensuring a fresh environment for subsequent testing activities.


Endpoint

URL: https://{your_base_url}.testgrid.io/api/execute-shell-adb-native/{device_id}

Method:POST

Request Parameters

ParameterTypeRequiredDescription
device_idIntegerYesUnique identifier of the target device


ParameterTypeRequiredDescription
user_tokenStringYesUser authentication token
commandStringYesShell command used to delete the log directory

Example Request

curl --location 'https://{your_base_url}.testgrid.io/api/execute-shell-adb-native/1'
--form 'user_token="YOUR_USER_TOKEN"'
--form 'command="shell rm -r /sdcard/Android/data/com.android.numeracle.screencapture/files/CallCapture/CallCaptureLogs"'


Example Response

{
"success": true,
"message": "Command executed successfully.",
"output": "",
"file_url": ""
}


Response Parameters

ParameterTypeDescription
successBooleanIndicates whether the command executed successfully
messageStringStatus message returned after command execution
outputStringOutput generated by the command execution
file_urlStringGenerated file URL, if applicable

Notes

  • Replace {device_id} with the target device ID.

  • The user_token must be valid and authorized to access the device.

  • The API executes the specified shell command directly on the device.

  • Exercise caution when modifying the command parameter, as incorrect commands may delete unintended files or directories.

  • The log directory path is application-specific and may vary across applications or versions.


Outcome

The API removes all log files from the specified device directory, helping maintain a clean test environment and preventing older log data from impacting future troubleshooting or automation activities.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article