Logs Command
The fastapi cloud logs command streams logs from your deployed FastAPI Cloud application directly in your terminal.
This is useful for debugging, monitoring application behavior, and troubleshooting issues without leaving your development environment.
fastapi cloud logs [PATH] [OPTIONS]Arguments:
[PATH]- Optional. Path to the folder containing the app (defaults to current directory)
Options:
--tail,-t- Number of log lines to show before streaming (default: 100)--since,-s- Show logs since a specific time (default: 5m)--follow,-f/--no-follow- Stream logs in real-time or fetch and exit (default: follow)
Examples
Section titled “Examples”Stream Logs in Real-Time
Section titled “Stream Logs in Real-Time”fastapi cloud logsThis starts streaming logs continuously until you press Ctrl+C. You’ll see:
logs Streaming logs for fastapi-rules-app (Ctrl+C to exit)...─────┃ 2024-01-15T10:30:45.123Z INFO: Application startup complete.┃ 2024-01-15T10:30:46.456Z INFO: GET /health 200 OK┃ 2024-01-15T10:30:47.789Z INFO: POST /items 201 CreatedFetch Recent Logs Without Streaming
Section titled “Fetch Recent Logs Without Streaming”fastapi cloud logs --no-followFetches the recent logs and exits immediately.
Customize Number of Log Lines
Section titled “Customize Number of Log Lines”fastapi cloud logs --tail 50Shows the last 50 log lines before streaming (or before exiting with --no-follow).
Filter by Time Range
Section titled “Filter by Time Range”fastapi cloud logs --since 1hShows logs from the last hour. Supported time formats:
s- seconds (e.g.,30s)m- minutes (e.g.,5m)h- hours (e.g.,1h)d- days (e.g.,2d)
What You’ll See
Section titled “What You’ll See”Each log line includes:
- Timestamp - When the log was generated (UTC)
- Level - The log level (DEBUG, INFO, WARNING, ERROR, CRITICAL)
- Message - The log message from your application
Example output:
┃ 2024-01-15T10:30:45.123Z INFO: Application startup complete.┃ 2024-01-15T10:30:46.456Z WARNING: Slow query detected (>500ms)┃ 2024-01-15T10:30:47.789Z ERROR: Connection refused: database unavailableRelated Documentation
Section titled “Related Documentation”- Logs - Complete guide to viewing logs in the dashboard