[英]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。
這是當前的解決方法。 所以當這個問題解決后,我認為你可以使用console.log
。 另外,我在問題跟蹤器中發現了這個問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.