gcloud beta logging write

NAME
gcloud beta logging write - write a log entry
SYNOPSIS
gcloud beta logging writeLOG_NAMEMESSAGE[--monitored-resource-labels=[KEY=VALUE, …,…]][--monitored-resource-type=MONITORED_RESOURCE_TYPE; default="global"][--payload-type=PAYLOAD_TYPE; default="text"][--severity=SEVERITY; default="DEFAULT"][--billing-account=BILLING_ACCOUNT_ID    |--folder=FOLDER_ID    |--organization=ORGANIZATION_ID    |--project=PROJECT_ID][GCLOUD_WIDE_FLAG]
DESCRIPTION
(BETA) Write a log entry. If the destination log does not exist, itwill be created. By default, all log entries written with this command arewritten with the "global" resource type.

gcloud beta logging write should be used for simple testing purposes. CheckCloud Logging agent for a proper way to send log entries:https://cloud.google.com/logging/docs/agent/

EXAMPLES
To create a log entry in a given log, run:
gcloudbetaloggingwriteLOG_NAME"A simple entry"

To create a high severity log entry, run:

gcloudbetaloggingwriteLOG_NAME"Urgent message"--severity=ALERT

To create a structured log, run:

gcloudbetaloggingwriteLOG_NAME'{"key": "value"}'--payload-type=json

To create a log entry with a custom resource type, run:

gcloudbetaloggingwriteLOG_NAME"A simple entry"--monitored-resource-type=gce_instance--monitored-resource-labels=zone=us-centra1-a,instance_id=1234
POSITIONAL ARGUMENTS
LOG_NAME
Name of the log where the log entry will be written.
MESSAGE
Message to put in the log entry. It can be JSON if you include--payload-type=json.
FLAGS
--monitored-resource-labels=[KEY=VALUE, …,…]
Monitored Resource labels to add to the payload
--monitored-resource-type=MONITORED_RESOURCE_TYPE; default="global"
Monitored Resource type to add to the payload
--payload-type=PAYLOAD_TYPE; default="text"
Type of the log entry payload.PAYLOAD_TYPE must be oneof:text,json.
--severity=SEVERITY; default="DEFAULT"
Severity level of the log entry.SEVERITY must be oneof:DEFAULT,DEBUG,INFO,NOTICE,WARNING,ERROR,CRITICAL,ALERT,EMERGENCY.
At most one of these can be specified:
--billing-account=BILLING_ACCOUNT_ID
Billing account of the log entries to write.
--folder=FOLDER_ID
Folder of the log entries to write.
--organization=ORGANIZATION_ID
Organization of the log entries to write.
--project=PROJECT_ID
Project of the log entries to write.

The Google Cloud project ID to use for this invocation. If omitted, then thecurrent project is assumed; the current project can be listed usinggcloudconfig list --format='text(core.project)' and can be set usinggcloud config set project PROJECTID.

--project and its fallbackcore/project property playtwo roles in the invocation. It specifies the project of the resource to operateon. It also specifies the project for API enablement check, quota, and billing.To specify a different project for quota and billing, use--billing-project orbilling/quota_project property.

GCLOUD WIDE FLAGS
These flags are available to all commands:--access-token-file,--account,--billing-project,--configuration,--flags-file,--flatten,--format,--help,--impersonate-service-account,--log-http,--project,--quiet,--trace-token,--user-output-enabled,--verbosity.

Run$gcloud help for details.

NOTES
This command is currently in beta and might change without notice. Thesevariants are also available:
gcloudloggingwrite
gcloudalphaloggingwrite

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-05-07 UTC.