I am writing logs in gcp logs using below command:
gcloud logging write my-test-log '{ "ServiceName": "$Service1", "SubsystemName": "$subsystem1") --payload-type=json
it is giving below error:
(gcloud.logging.write) unrecognized arguments.
Please suggest
You are receiving that error because you have some syntax errors.
As LundinCast said, the correct command should be:
You only will receive the following output:
Please check the following documentation for further information: gcloud logging write
And you could verify if it works listing your project's logs:
or reading the log entry:
Edit 1
I found the problem in my original answer. To get the value of a variable in a json format it is necessary to add
"'"
so the command should be something like:Where the content of $variable is
my-variable-content