簡體   English   中英

Stackdriver 日志記錄 - 為什么我的有效負載在 Runtime V8 中沒有正確顯示

[英]Stackdriver logging - Why is not my payload showing correctly in Runtime V8

我添加了一條簡單的日志消息,並在 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});

在此處輸入圖像描述

更新
如果將項目降級為 ["runtimeVersion": "DEPRECATED_ES5"] 有效負載工作正常。
如果我在新的“運行時 Chrome V8”中運行項目,則有效負載不起作用。

我也有同樣的情況。 在這種情況下,我使用Logger.log而不是console.log 所以請進行如下修改並再次測試。

從:

console.log({message: 'Function Input', initialData: parameters});

至:

Logger.log({message: 'Function Input', initialData: parameters});

結果:

當使用Logger.log作為值時,會得到以下結果。 在這種情況下,即使啟用了 V8 運行時,也會在 Stackdriver 上解析 object。

在此處輸入圖像描述

筆記:

參考:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM