Stackdriver 日志记录 - 为什么我的负载在运行时 V8 中没有正确显示

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”中运行项目,则有效负载不起作用。

Tan*_*ike 5

我也有同样的情况。在这种情况下,我使用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 中进行解析。

在此输入图像描述

笔记:

参考: