# How to read logs (https://developer.godaddy.com/en/docs/api-users/hosting/read-logs)

---
title: How to read logs
description: >-
  Fetch application logs for a hosting app by environment, source stream, and
  time range.
keywords: >-
  GET /apps/{appId}/logs, variant preview publish logs, source stdout stderr,
  since time range, level filter, hosting.log:read
agentNotes:
  scopes:
    - 'hosting.log:read'
  idempotent: true
  destructive: false
  failureRecovery: >-
    Log reads are safe to retry. Empty response means no logs match the filters
    — adjust source, since, or variant.
related:
  tutorials:
    - title: Deploy your Node.js app
      href: /docs/api-users/hosting/workflows/deploy-nodejs-app
  guides:
    - title: Troubleshoot Hosting
      href: /docs/api-users/troubleshoot/hosting
  concepts:
    - title: Hosting concepts
      href: /docs/api-users/hosting/concepts
  apis:
    - title: Logs reference
      href: /docs/references/rest/hosting/logs
---

## Overview

This page covers fetching logs for a hosted app. The logs endpoint returns application output from both `PREVIEW` and `PUBLISH` environments and supports filtering by source stream (`STDOUT` or `STDERR`), severity level, and time range. By default, logs return the last 24 hours; you can request up to 7 days in the past.

Go to [Deploy your Node.js app](https://developer.godaddy.com/docs/api-users/hosting/workflows/deploy-nodejs-app) if you haven't created and deployed an app yet. Go to [Troubleshoot Hosting](https://developer.godaddy.com/docs/api-users/troubleshoot/hosting) for guidance on diagnosing specific failures. For the complete list of query parameters and response schema, see [Logs API reference](https://developer.godaddy.com/docs/references/rest/hosting/logs).

## Prerequisites

The following prerequisites are required before you can read logs for your app:

* a [Personal Access Token](https://developer.godaddy.com/personal-access-token) with the `hosting.log:read` scope

## Get logs

The following procedure fetches all logs from the `PREVIEW` variant (default).

* Fetch logs from `PREVIEW`:

  ```bash tab="curl"
  curl -s "$BASE_URL/v1/hosting/apps/$APP_ID/logs" \
    -H "Authorization: Bearer $GODADDY_PAT" | jq .
  ```

  ```js tab="Node"
  const res = await fetch(
    `${process.env.BASE_URL}/v1/hosting/apps/${appId}/logs`,
    { headers: { Authorization: `Bearer ${process.env.GODADDY_PAT}` } },
  );
  const logs = await res.json();
  ```

  ```python tab="Python"
  resp = requests.get(
      f"{os.environ['BASE_URL']}/v1/hosting/apps/{app_id}/logs",
      headers={"Authorization": f"Bearer {os.environ['GODADDY_PAT']}"},
  )
  logs = resp.json()
  ```

  ```go tab="Go"
  req, _ := http.NewRequest("GET",
      os.Getenv("BASE_URL")+"/v1/hosting/apps/"+appID+"/logs", nil)
  req.Header.Set("Authorization", "Bearer "+os.Getenv("GODADDY_PAT"))
  resp, _ := http.DefaultClient.Do(req)
  defer resp.Body.Close()
  ```

## Read production logs

The following procedure fetches all logs from the `PUBLISH` variant. Every app has two parallel variants: `PREVIEW` (working copy) and `PUBLISH` (live traffic). Go to [Hosting concepts](https://developer.godaddy.com/docs/api-users/hosting/concepts#variants) for more information.

* Fetch production logs:

## Filter by severity level

The following procedure fetches only error-level logs.

* Fetch error logs:

  ```bash tab="curl"
  curl -s "$BASE_URL/v1/hosting/apps/$APP_ID/logs?level=ERROR" \
    -H "Authorization: Bearer $GODADDY_PAT" | jq .
  ```

  ```js tab="Node"
  const res = await fetch(
    `${process.env.BASE_URL}/v1/hosting/apps/${appId}/logs?level=ERROR`,
    { headers: { Authorization: `Bearer ${process.env.GODADDY_PAT}` } },
  );
  const logs = await res.json();
  ```

  ```python tab="Python"
  resp = requests.get(
      f"{os.environ['BASE_URL']}/v1/hosting/apps/{app_id}/logs",
      headers={"Authorization": f"Bearer {os.environ['GODADDY_PAT']}"},
      params={"level": "ERROR"},
  )
  logs = resp.json()
  ```

  ```go tab="Go"
  req, _ := http.NewRequest("GET",
      os.Getenv("BASE_URL")+"/v1/hosting/apps/"+appID+"/logs?level=ERROR",
      nil)
  req.Header.Set("Authorization", "Bearer "+os.Getenv("GODADDY_PAT"))
  resp, _ := http.DefaultClient.Do(req)
  defer resp.Body.Close()
  ```

## Filter by time range

The following procedure fetches logs written at or after a specific timestamp.

* Fetch logs since the timestamp:

  ```bash tab="curl"
  curl -s "$BASE_URL/v1/hosting/apps/$APP_ID/logs?since=2024-01-15T10:00:00Z" \
    -H "Authorization: Bearer $GODADDY_PAT" | jq .
  ```

  ```js tab="Node"
  const res = await fetch(
    `${process.env.BASE_URL}/v1/hosting/apps/${appId}/logs?since=2024-01-15T10:00:00Z`,
    { headers: { Authorization: `Bearer ${process.env.GODADDY_PAT}` } },
  );
  const logs = await res.json();
  ```

  ```python tab="Python"
  resp = requests.get(
      f"{os.environ['BASE_URL']}/v1/hosting/apps/{app_id}/logs",
      headers={"Authorization": f"Bearer {os.environ['GODADDY_PAT']}"},
      params={"since": "2024-01-15T10:00:00Z"},
  )
  logs = resp.json()
  ```

  ```go tab="Go"
  req, _ := http.NewRequest("GET",
      os.Getenv("BASE_URL")+"/v1/hosting/apps/"+appID+"/logs?since=2024-01-15T10:00:00Z",
      nil)
  req.Header.Set("Authorization", "Bearer "+os.Getenv("GODADDY_PAT"))
  resp, _ := http.DefaultClient.Do(req)
  defer resp.Body.Close()
  ```

## Common errors

The following table lists common errors and recommended actions:

| Status | Cause                                    | Action                                                                                                                       |
| ------ | ---------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| `401`  | Expired or revoked PAT, or missing scope | Confirm the token includes `hosting.log:read`                                                                                |
| `404`  | App id not found                         | Confirm the id from `GET /apps`                                                                                              |
| `400`  | Invalid parameter value                  | Use uppercase for `variant` (`PREVIEW` or `PUBLISH`), `source` (`STDOUT` or `STDERR`), and `level` (`INFO`, `WARN`, `ERROR`) |
| `429`  | Rate limit exceeded                      | Back off and retry. Go to [Rate limits](https://developer.godaddy.com/docs/api-users/rate-limits) for handling guidance                                   |
