gcloud functions logs read: Cloud Functions Logs
gcloud functions logs read returns recent log entries for a Cloud Function, scoped by name and region.
After deploying a function, surfacing its latest logs in the pipeline helps catch cold-start or runtime errors before they reach production traffic.
What it does
gcloud functions logs read fetches log entries for a function, most recent first. You scope by function name, --region, and --limit. For 2nd-gen functions add --gen2 so it targets the right resource.
Common usage
gcloud functions logs read my-fn \
--region=us-central1 --limit=50
# 2nd-gen function
gcloud functions logs read my-fn --gen2 \
--region=us-central1 --limit=50Flags
| Flag | What it does |
|---|---|
| <FUNCTION> | Function name to read logs for |
| --region <region> | Region the function is deployed in |
| --limit <n> | Maximum number of log entries |
| --gen2 | Target a 2nd-generation function |
| --start-time / --end-time | Bound the time window |
In CI
Pin --region and --limit so the step is bounded and never prompts. For broader queries (cross-function or by severity) prefer gcloud logging read. Authenticate keylessly with Workload Identity Federation; the identity needs roles/logging.viewer.
Common errors in CI
"Cannot find function [name] in region [region]" means a wrong name, region, or a gen2 function queried without --gen2. "PERMISSION_DENIED" needs roles/logging.viewer. An empty result usually means the time window is too narrow or the function has not run recently.