gcloud debug logpoints - commands for interacting with Cloud Debugger logpoints
gcloud debug logpoints COMMAND [--target=(ID|DESCRIPTION_REGEXP)] [GCLOUD_WIDE_FLAG ...]
Logpoints allow you to inject logging into running services without restarting or interfering with the normal function of the service. Log output will be sent to the appropriate log for the target's environment. On App Engine, for example, output will go to the request log.
The following command would log the value of the "name" attribute of the "product" variable whenever any request executes line 123 of the file product.py:
$ gcloud debug logpoints create product.py:123 \ "No description for {product.name}"
The log output will appear wherever explicit logging output from your program is normally written. For example, for an App Engine Standard application, the output would appear in the request log.
If you want to log output only when certain runtime conditions are met, you can add a "--condition" option:
$ gcloud debug logpoints create product.py:123 \ "Suspicious price: {product.name} costs {price}" \ --condition "price < .50"
Logpoints remain active for 24 hours after creation. If you want to disable a logpoint, use the logpoints delete command:
$ gcloud debug logpoints delete product.*
The above command would delete all logpoints in any file whose name begins with "product". If you want to delete only a single logpoint, you should first determine the logpoint ID using the logpoints list command, then delete that specific ID:
$ gcloud debug logpoints list ID LOCATION ... \ 567890abcdef1-1234-56789 product.py:123 ... $ gcloud debug logpoints delete 567890abcdef1-1234-56789
For App Engine services, logpoint resources include the "logQuery" property, which is suitable for use with the "gcloud beta logging read" command. You can save this property's value and use it to read logs from the command line:
$ log_query=$(gcloud debug logpoints create product.py:123 \ "No description for {product.name}" --format="value(logQuery)") $ gcloud logging read "$log_query"
- --target=(ID|DESCRIPTION_REGEXP)
The debug target. It may be a target ID or name obtained from 'debug targets list', or it may be a regular expression uniquely specifying a debuggee based on its description or name. For App Engine projects, if not specified, the default target is the most recent deployment of the default module and version.
These flags are available to all commands: --help.
Run $ gcloud help for details.
COMMAND is one of the following:
- create
Add debug logpoints to a Cloud Debugger debug target (debuggee).
- delete
Delete debug logpoints for a Cloud Debugger debug target (debuggee).
- list
List the debug logpoints for a Cloud Debugger debug target (debuggee).
This variant is also available:
$ gcloud beta debug logpoints