Cloud Logging

Logs Explorer

Logs from Cloud Run, GKE, VMs and Google services flow into Cloud Logging automatically. Write structured JSON to stdout and fields like severity become searchable.

import json
print(json.dumps({"severity": "ERROR", "message": "payment failed", "orderId": 1001, "provider": "razorpay"}))

Example

Query logs from the CLI:

gcloud logging read 'resource.type="cloud_run_revision" AND severity>=ERROR' --limit=2 --format="value(timestamp, jsonPayload.message)"

Example output

2026-10-07T09:14:03.512Z	payment failed
2026-10-07T08:51:47.208Z	database timeout

Log Routing

  • Log sinks export logs to BigQuery (analysis), Cloud Storage (long retention) or Pub/Sub (other tools).
  • Exclusion filters drop noisy logs to reduce cost.
  • Log-based metrics turn log patterns (e.g. "payment failed") into charts and alerts.