View Logs
View logs from your running applications to monitor performance, diagnose issues, and track application behavior. Serverpod Cloud automatically collects logs from your applications. You can view these logs using the scloud log
command, which provides powerful filtering and real-time monitoring capabilities.
Viewing Deployment Logs
Basic Log Viewing
To view logs for your deployment:
scloud log
This displays the most recent logs for your deployment.
Viewing Recent Logs with Time Shortcuts
You can quickly view logs from recent time periods using time-based shortcuts:
# View logs from the last 120 seconds
scloud log 120s
# View logs from the last 5 minutes
scloud log 5m
# View logs from the last 12 hours
scloud log 12h
# View logs from the last 7 days
scloud log 7d
These shortcuts provide a convenient way to filter logs by recent time periods without having to specify exact timestamps.
Filtering Logs by Time
You can filter logs using the --after
and --before
options with ISO 8601 timestamp format:
# View logs after a specific time
scloud log --after "2023-06-15T14:00:00Z"
# View logs before a specific time
scloud log --before "2023-06-15T16:00:00Z"
# View logs in a time range
scloud log --after "2023-06-15T14:00:00Z" --before "2023-06-15T16:00:00Z"
The timestamp format is flexible and supports various levels of precision:
# Full ISO 8601 format with seconds and timezone
scloud log --after "2023-06-15T14:00:00Z"
# Without seconds
scloud log --after "2023-06-15T14:00"
# Without minutes and seconds
scloud log --after "2023-06-15T14"
# Just the date (starts at 00:00:00)
scloud log --after "2023-06-15"
Real-time Log Streaming
To continuously stream logs as they are generated:
scloud log --tail
Press Ctrl+C
to stop the stream.
⚠️ Note: The
--tail
flag cannot be used together with the--after
or--before
options.
Display Logs in UTC Time
By default, logs are displayed in your local time zone. To view logs in UTC time:
scloud log --utc
Viewing Build Logs
To diagnose issues during the deployment process, you can view the build logs for your deployments:
Basic Build Log Viewing
To view build logs for your most recent deployment:
scloud status deploy --build-log
Viewing Logs for Specific Deployments
You can view build logs for specific projects or deployments:
# View build logs for a specific project
scloud status deploy --build-log
# View build logs for a specific deployment by index (0 is most recent)
scloud status deploy 0 --build-log
# View build logs for a specific deployment by ID
scloud status deploy abc123 --build-log
Understanding Build Logs
Build logs show the complete output from the build process, including:
- Package installation steps
- Compilation messages
- Warning and error messages
If a deployment failed, the build logs will help you identify where the failure occurred and any specific error messages.
💡 Tips for Build Logs
-
Use
scloud status deploy --list
to see all recent deployments before viewing logs for a specific one -
Redirect lengthy build logs to a file for easier analysis:
scloud status deploy --build-log > build-log.txt
-
Filter for specific messages:
scloud status deploy --build-log | grep ERROR
💡 Best Practices
-
Use specific time ranges when debugging known issues to reduce noise
-
Enable UTC mode (
--utc
) when collaborating with team members in different time zones -
Combine with
grep
for further filtering:scloud log | grep ERROR
-
Redirect output to file for persistence or sharing:
scloud log > project_logs.txt
Log Format
Each log entry includes:
- Timestamp
- Log level (INFO, ERROR, etc.)
- Origin service (API, insights, or web)
- Message content
🧪 Example Scenarios
Monitoring During Critical Operations
# Stream logs in real-time with UTC timestamps
scloud log --tail --utc
Investigating a Specific Incident
# View logs around a reported error
scloud log --after "2023-07-10T13:45:00Z" --before "2023-07-10T14:15:00Z"
Troubleshooting
Invalid timestamp format
If you see an error about invalid timestamp format, ensure you're using ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ
).
No logs appearing
- Check if your time range is correct
- Ensure your application is running and generating logs