Skip to content

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.

Terminal window
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)
Terminal window
fastapi cloud logs

This 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 Created
Terminal window
fastapi cloud logs --no-follow

Fetches the recent logs and exits immediately.

Terminal window
fastapi cloud logs --tail 50

Shows the last 50 log lines before streaming (or before exiting with --no-follow).

Terminal window
fastapi cloud logs --since 1h

Shows 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)

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 unavailable
  • Logs - Complete guide to viewing logs in the dashboard