gcloud-logging-logs-list
List logs from Google Cloud Logging
TLDR
List all logs in the current project
List all logs for a specific log bucket and location
List all logs for a specific view in a log bucket
List logs with a filter expression
List a specified number of logs
List logs sorted by a specific field in ascending or descending order (~ for descending)
List logs sorted by multiple fields
List logs with verbose output, showing additional details
SYNOPSIS
gcloud logging logs list [LOG_NAMES ...] [--log-filter=EXPRESSION] [--limit=LIMIT] [--page-size=PAGE_SIZE] [--sort-by=FIELD,...] [--uri] [GLOBAL_FLAGS]
PARAMETERS
LOG_NAMES ...
One or more log names to list. If unspecified, all logs within the project are listed. Log names often include service prefixes, like cloudfunctions.googleapis.com%2Fcloud-functions.
--log-filter=EXPRESSION
A filter expression that filters the logs listed by name. This allows for advanced filtering based on log properties, such as resource type or service. For example: 'resource.type="gce_instance"'.
--limit=LIMIT
The maximum number of logs to list. This is useful for restricting the output size for very large projects or for quick checks.
--page-size=PAGE_SIZE
The maximum number of logs to retrieve per API call. This can affect performance and memory usage for commands that return a large number of results.
--sort-by=FIELD,...
A comma-separated list of fields to sort the results by. The default sort order is typically alphanumeric by log name.
--uri
If specified, only the URIs of the logs are displayed, providing a concise output suitable for scripting.
DESCRIPTION
gcloud logging logs list is a command within the Google Cloud SDK that allows users to enumerate the logs present in a specified Google Cloud project. This command is part of the gcloud logging component, which provides comprehensive tools for interacting with Google Cloud Logging. By default, if no specific log names are provided, it fetches and displays a list of all distinct log names that have recorded entries within the project. Users can also specify one or more log names as positional arguments to filter the output and list only those specific logs. This functionality is crucial for administrators and developers to understand the logging landscape of their projects, identify active log streams, and prepare for more granular operations like reading specific log entries or managing log sinks.
CAVEATS
This command requires the Google Cloud SDK to be installed and configured with appropriate authentication. The user's Google Cloud IAM role must include permissions to list logs (e.g., logging.logs.list or the broader roles/logging.viewer). The command operates on the currently configured project, which can be overridden using the global --project flag. Listing a very large number of logs might take time, and pagination options (--limit, --page-size) can be helpful for performance management.
PERMISSIONS REQUIRED
To successfully execute gcloud logging logs list, your Google Cloud account must have an IAM role that grants the logging.logs.list permission. Common roles that include this permission are roles/logging.viewer (Logs Viewer) or roles/owner (Project Owner).
DEFAULT PROJECT
The command operates on the Google Cloud project that is currently configured in your gcloud CLI environment. You can set or change the default project using gcloud config set project [PROJECT_ID] or by providing the global --project=[PROJECT_ID] flag with the command.
HISTORY
The gcloud command-line tool is a core component of the Google Cloud SDK, first released in 2013, and continuously updated. The logging component, which interfaces with Google Cloud Logging (formerly Stackdriver Logging), has evolved significantly to support the growing capabilities of cloud logging. The logs list subcommand has been a fundamental part of the logging management toolset since early versions, providing a basic but essential inventory capability for cloud log data.
SEE ALSO
gcloud logging logs describe(1), gcloud logging logs delete(1), gcloud logging read(1), gcloud logging sinks list(1)