Best Practice Guide – Send and receive device logs

This guide goes over the best practice to send and receive device logs as well as view them at JFrog Connect platform. The best practice guidelines are used JFrog Connect General API to send logs from connected devices to JFrog Connect platform in the quickest way.

Send device logs approach

JFrog Connect provides an easy-to-use way to send device logs from any type and view/download them from JFrog Connect platform. These logs may help you to have a better understanding of the product behavior in the long-run, also, can be useful for debugging issues and investigation.

As a best practice, we would like to send daily/weekly logs of our device application, this can be done by using a separate script that will run by service manager/crontab, or inside the application code itself. In this best practice guide, we will create a weekly logs push script that runs once a week from each device.

Guidelines

Those guidelines require the device to be connected to JFrog Connect platform. For more information about the Logs feature, read JFrog Connect docs.

1. Create a python script (is it possible to work with any other programing language with HTTP library).

This script pulls JFrog Connect account tokens, take the path of the log file and send it to JFrog Connect servers. Make sure to change the values of FILE_NAME & FILE_PATH as needed.

2. To run our script each day or week, we will use crontab software and schedule when to call the python script.

Here is a ready-to-use command you need to run on the device terminal to creates a cron job:

echo “* * 1 * * python /home/app/send_logs.py” >> /etc/crontab

Make sure to change the path (in red) which indicates the place you store the python script.

From now on, your device will run the python script once a day.

3. Under the ‘Devices’ category, each device has a Log section where you will be able to view and download the received device logs.

JFrog Connect is a modern Linux-first IoT platform designed to efficiently update, control and monitor edge and IoT devices at scale.