Commands
log
View and stream logs from Sentry projects.
Commands
sentry log list
List and stream logs from a project.
# Auto-detect from DSN or configsentry log list
# Explicit org and projectsentry log list <org>/<project>
# Search for project across all accessible orgssentry log list <project>Arguments:
| Argument | Description |
|---|---|
<org>/<project> | Explicit organization and project (e.g., my-org/backend) |
<project> | Search for project by name across all accessible organizations |
Options:
| Option | Description |
|---|---|
-n, --limit <n> | Number of log entries to show (1-1000, default: 100) |
-q, --query <query> | Filter query (Sentry search syntax) |
-f, --follow [interval] | Stream logs in real-time (optional: poll interval in seconds, default: 2) |
--json | Output as JSON |
Examples:
# List last 100 logs (default)sentry log listTIMESTAMP LEVEL MESSAGE2024-01-20 14:22:01 info User login successful2024-01-20 14:22:03 debug Processing request for /api/users2024-01-20 14:22:05 error Database connection timeout2024-01-20 14:22:06 warn Retry attempt 1 of 3
Showing 4 logs.Stream logs in real-time:
# Stream with default 2-second poll intervalsentry log list -f
# Stream with custom 5-second poll intervalsentry log list -f 5Filter logs:
# Show only error logssentry log list -q 'level:error'
# Filter by message contentsentry log list -q 'database'Limit results:
# Show last 50 logssentry log list --limit 50
# Show last 500 logssentry log list -n 500Combine options:
# Stream error logs from a specific projectsentry log list my-org/backend -f -q 'level:error'sentry log view
View details of a specific log entry.
# Auto-detect from DSN or configsentry log view <log-id>
# Explicit org and projectsentry log view <org>/<project> <log-id>
# Search for project across all accessible orgssentry log view <project> <log-id>Arguments:
| Argument | Description |
|---|---|
<log-id> | The 32-character hexadecimal log ID |
<org>/<project> | Explicit organization and project (e.g., my-org/backend) |
<project> | Search for project by name across all accessible organizations |
Options:
| Option | Description |
|---|---|
-w, --web | Open in browser |
--json | Output as JSON |
Example:
sentry log view 968c763c740cfda8b6728f27fb9e9b01Log 968c763c740c...════════════════════
ID: 968c763c740cfda8b6728f27fb9e9b01Timestamp: 2024-01-20 14:22:05Severity: ERROR
Message: Database connection timeout after 30s
─── Context ───
Project: backendEnvironment: productionRelease: 1.2.3
─── SDK ───
SDK: sentry.python 1.40.0
─── Trace ───
Trace ID: abc123def456abc123def456abc12345Span ID: 1234567890abcdefLink: https://sentry.io/organizations/my-org/explore/traces/abc123...
─── Source Location ───
Function: connect_to_databaseFile: src/db/connection.py:142Open in browser:
sentry log view 968c763c740cfda8b6728f27fb9e9b01 -wWith explicit project:
sentry log view my-org/backend 968c763c740cfda8b6728f27fb9e9b01Finding Log IDs
Log IDs can be found:
- In the output of
sentry log list(shown as trace IDs in brackets) - In the Sentry UI when viewing log entries
- In the
sentry.item_idfield of JSON output
JSON Output
Use --json for machine-readable output:
sentry log list --json | jq '.[] | select(.level == "error")'In streaming mode with --json, each log entry is output as a separate JSON object (newline-delimited JSON), making it suitable for piping to other tools.