Hen*_*rik 2 logging google-apps-script stackdriver google-cloud-stackdriver
我添加了一条简单的日志消息,然后在 Stackdriver 中看到了该日志。
但有效负载不会拆分为单独的值。
问题在于有效负载显示为包含消息和有效负载的一大串。
我需要一个值列表,以便我可以查询 ex isValid 或内容。
如何将有效负载获取到 Stackdriver 日志记录中的值列表?
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});
Run Code Online (Sandbox Code Playgroud)
更新
如果将项目降级到 ["runtimeVersion": "DEPRECATED_ES5"] 有效负载工作正常。
如果我在新的“运行时 Chrome V8”中运行项目,则有效负载不起作用。
我也有同样的情况。在这种情况下,我使用Logger.log而不是console.log. 所以请修改如下并再次测试。
console.log({message: 'Function Input', initialData: parameters});
Run Code Online (Sandbox Code Playgroud)
Logger.log({message: 'Function Input', initialData: parameters});
Run Code Online (Sandbox Code Playgroud)
当Logger.log用作该值时,将获得以下结果。在这种情况下,即使启用了 V8 运行时,该对象也会在 Stackdriver 中进行解析。
这是当前的解决方法。因此,当这个问题解决后,我认为您可以使用console.log. 另外,我在问题跟踪器中发现了这个问题。
| 归档时间: |
|
| 查看次数: |
254 次 |
| 最近记录: |