I add a simple log message and I see the log in Stackdriver.
But the payload is not splited to separate values.
The problem is that Payload is shown as one big string with message and payload.
I need a list of values so I can Query for ex isValid or content.
How can I get the payload to a list of values inside Stackdriver logging?
https://developers.google.com/apps-script/guides/logging#using_cloud_logging
// Log a JSON object at a DEBUG level. The log is labeled
// with the message string in the log viewer, and the JSON content
// is displayed in the expanded log structure under "jsonPayload".
var parameters = {
isValid: true,
content: 'some string',
timestamp: new Date()
};
console.log({message: 'Function Input', initialData: parameters});
Update
If downgrade project to ["runtimeVersion": "DEPRECATED_ES5"] payload work correct.
If I run project in new "Runtime Chrome V8" the payload is NOT working.
I had the same situation. In such case, I use Logger.log
instead of console.log
. So please modify as follows and test it again.
console.log({message: 'Function Input', initialData: parameters});
Logger.log({message: 'Function Input', initialData: parameters});
When Logger.log
is used for the value, the following result is obtained. In this case, even when V8 runtime is enabled, the object is parsed at the Stackdriver.
This is a current workaround. So when this issue was resolved, I think that you can use console.log
. Also, I found this issue at the issue tracker.