Skip to main content

How to export logs

The script allows you to retrieve and display logs from a specified environment of a Divio application for a given range of date and time. The logs are fetched from the Divio API and printed to the terminal. Additionally, the logs are saved to a text file for easy search and analysis.


Before running the script, ensure you have the following requirements in place:

  1. Python 3.x: The script requires Python 3.x. If you don't have it installed, you can download it from the official Python website.
  2. requests library: The script uses the requests library to make HTTP requests to the Divio API. Install the library by running the following command in your terminal:
pip install requests

Running the Script

  1. Copy the Python script from to any directory on your system.
  2. In the terminal, cd to the directory where you copied the script.
  3. Run the script with the following command, providing the required command-line arguments:
python "2023-08-13T00:00" "2023-08-13T23:00" "live" "APPLICATION_UUID" "YOUR_API_TOKEN"


  • "2023-08-13T00:00" with the desired start date and time in the format YYYY-MM-DDThh:mm.
  • "2023-08-13T23:00" with the desired end date and time in the format YYYY-MM-DDThh:mm.
  • "live" with the slug of the environment (e.g., 'live' or 'test').
  • "APPLICATION_UUID" with the UUID of the Divio application containing the target environment. Extract the UUID from the dashboard URL of the application after the /app/ part. For example, if the application URL is{uuid}/{uuid}/, the application UUID would be "{uuid}".
  • "YOUR_API_TOKEN" with your Divio API token.

Once executed, the script will display the logs on the console in reverse chronological order, showing each log's timestamp and message. Simultaneously, it will save the logs to a file named logs.txt in the same directory as the script.

The timestamp format in the logs is truncated to milliseconds for a more concise display.