Skip to content
Latchkey

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

Terminal
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=50

Flags

FlagWhat it does
<FUNCTION>Function name to read logs for
--region <region>Region the function is deployed in
--limit <n>Maximum number of log entries
--gen2Target a 2nd-generation function
--start-time / --end-timeBound 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.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →