How to read logs
View as MarkdownFetch application logs for a hosting app by environment, source stream, and time range.
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 if you haven't created and deployed an app yet. Go to Troubleshoot Hosting for guidance on diagnosing specific failures. For the complete list of query parameters and response schema, see Logs API reference.
Prerequisites
The following prerequisites are required before you can read logs for your app:
- a Personal Access Token with the
hosting.log:readscope
Get logs
The following procedure fetches all logs from the PREVIEW variant (default).
-
Fetch logs from
PREVIEW:curl -s "$BASE_URL/v1/hosting/apps/$APP_ID/logs" \ -H "Authorization: Bearer $GODADDY_PAT" | jq .
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 for more information.
-
Fetch production logs:
curl -s "$BASE_URL/v1/hosting/apps/$APP_ID/logs?variant=PUBLISH" \ -H "Authorization: Bearer $GODADDY_PAT" | jq .
Filter by severity level
The following procedure fetches only error-level logs.
-
Fetch error logs:
curl -s "$BASE_URL/v1/hosting/apps/$APP_ID/logs?level=ERROR" \ -H "Authorization: Bearer $GODADDY_PAT" | jq .
Filter by time range
The following procedure fetches logs written at or after a specific timestamp.
-
Fetch logs since the timestamp:
curl -s "$BASE_URL/v1/hosting/apps/$APP_ID/logs?since=2024-01-15T10:00:00Z" \ -H "Authorization: Bearer $GODADDY_PAT" | jq .
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 for handling guidance |
Agent & Automation Notes
hosting.log:readRelated
API References
Guides
Concepts
Tutorials
Last updated on
How is this guide?