LinuxCommandLibrary

gcloud-logging-logs-list

List logs from Google Cloud Logging

TLDR

List all logs in the current project

$ gcloud logging logs list
copy

List all logs for a specific log bucket and location
$ gcloud logging logs list --bucket=[bucket_id] --location=[location]
copy

List all logs for a specific view in a log bucket
$ gcloud logging logs list --bucket=[bucket_id] --location=[location] --view=[view_id]
copy

List logs with a filter expression
$ gcloud logging logs list --filter="[expression]"
copy

List a specified number of logs
$ gcloud logging logs list --limit=[number]
copy

List logs sorted by a specific field in ascending or descending order (~ for descending)
$ gcloud logging logs list --sort-by="[field_name]"
copy

List logs sorted by multiple fields
$ gcloud logging logs list --sort-by="[field1],~[field2]"
copy

List logs with verbose output, showing additional details
$ gcloud logging logs list --verbosity=debug
copy

SYNOPSIS

gcloud logging logs list [--filter=EXPRESSION] [--limit=LIMIT] [--page-size=SIZE] [--format=FORMAT] [--project=PROJECT_ID]

PARAMETERS

--filter=EXPRESSION
    Filter expression restricting listed logs (e.g., 'name =~ "compute.googleapis.com%"')

--limit=LIMIT
    Maximum number of logs to return (default unlimited)

--page-size=SIZE
    Maximum logs per page of results (default 50, max 1000)

--format=FORMAT
    Output format (e.g., 'table(name,description)', 'json', 'yaml')

--project=PROJECT_ID
    ID of Google Cloud project (overrides default)

--configuration=CONFIGURATION
    Active configuration to use (overrides default)

--quiet, -q
    Disable most feedback and progress messages

DESCRIPTION

The gcloud logging logs list command retrieves a list of log names available in a Google Cloud project using Cloud Logging (formerly Stackdriver Logging). It helps administrators and developers identify and manage logs for troubleshooting, monitoring, and auditing purposes.

This command queries the Logging API to enumerate logs, which are identified by resource names like projects/[PROJECT_ID]/logs/[LOG_ID]. Logs capture events from Google Cloud services, applications, and custom sources. Use it to discover logs before reading entries with gcloud logging entries list or deleting them.

Output includes log names, display names, and descriptions. Customize results with filters for specific logs (e.g., by name pattern or labels), limits on count, or pagination. Requires logging.logs.list IAM permission, typically granted via Logging Viewer role. Integrates with gcloud global flags for project selection and output formatting.

CAVEATS

Requires logging.logs.list IAM permission; lists only project-owned logs, not aggregated from folders/organizations unless specified; filter syntax follows Logging query language.

EXAMPLE

gcloud logging logs list --filter="name =~ 'cloudaudit.googleapis.com%' --limit=10
Lists up to 10 audit logs matching the pattern.

PERMISSIONS

Needs Logging Viewer role (roles/logging.viewer) or equivalent; use gcloud projects get-iam-policy to check.

HISTORY

Introduced in Google Cloud SDK v130 (2017) as part of Stackdriver Logging tools; rebranded to Cloud Logging in 2020 with API v2 support; evolved for better integration with Operations Suite.

SEE ALSO

journalctl(1), logadm(8)

Copied to clipboard