简体   繁体   English

Google Apps 脚本日志(网络应用程序)未显示在新界面中

[英]Google Apps Script logs (web app) don't show up in the new interface

Apps Script has recently moved the StackDriver logs into the Apps Script dashboard , page 'Execution'. Apps Script 最近将 StackDriver 日志移到了Apps Script 仪表板的“执行”页面。

Problem is, the logs won't show up in the dashboard for Apps Script web apps.问题是,日志不会显示在 Apps 脚本 web 应用程序的仪表板中。 I can see the new execution line when I do a request to the Apps Script web app, but the line won't expand to show the logs.当我向 Apps 脚本 web 应用发出请求时,我可以看到新的执行行,但该行不会展开以显示日志。

I'm using the Stackdriver Logging:我正在使用 Stackdriver 日志记录:

function doPost(e) {
  console.info('my log');
}

Curiously, it works when I call the dev url (Deployment column is tagged as 'Head'), the line does expend when I click on it and I can see the logs, but for the exact same application it does not work when I call the production url ending with /exec (Deployment column is tagged as 'Version 2').奇怪的是,当我调用 dev url(部署列被标记为“Head”)时它起作用了,当我点击它时该行确实扩展并且我可以看到日志,但是对于完全相同的应用程序它在我调用时不起作用生产 url 以 /exec 结尾(部署列标记为“版本 2”)。

Also, it works with GET requests, but not with POST requests.此外,它适用于 GET 请求,但不适用于 POST 请求。

The web app is deployed with the permissions below:使用以下权限部署 web 应用程序:

  • Execute the app as 'Me'以“我”身份执行应用程序
  • Who can access to the app: anyone, even anonymous谁可以访问该应用程序:任何人,甚至是匿名的
  • Drive sharing settings: only specific people can access驱动器共享设置:只有特定的人可以访问

在此处输入图像描述

Is it a bug in their new interface or am I missing something?这是他们新界面中的错误还是我遗漏了什么?

I was able to work around this issue by creating a Cloud Console project at https://console.cloud.google.com and associating the Apps Script with that new project.我能够通过在https://console.cloud.google.com创建 Cloud Console 项目并将 Apps 脚本与该新项目相关联来解决此问题。

After jumping through the required hoops of setting up an OAuth Consent screen and re-authorizing the script, I am able to see logs from anonymous requests in the logging section of the Cloud Console.在跳过设置 OAuth 同意屏幕并重新授权脚本所需的步骤后,我能够在 Cloud Console 的日志记录部分看到来自匿名请求的日志。

Whilst you can of course associate your apps script with a cloud project, and go down that route, that can be tricky in many organisations.虽然您当然可以将您的应用程序脚本与云项目相关联,然后沿着这条路线走下去,但这在许多组织中可能会很棘手。

Instead, whilst you have the relevant apps script open, navigate to the "Project Settings" screen.相反,当您打开相关的应用程序脚本时,导航到“项目设置”屏幕。 Under "General settings" there's a checkbox for "Log uncaught exceptions to Cloud logs".在“常规设置”下有一个“记录未捕获的云日志异常”复选框。 Ensure that is not checked, and if necessary re-deploy your web app.确保未选中,并在必要时重新部署您的 Web 应用程序。 You should then find that logs re-appear in the "Executions" screen.然后您应该会发现日志重新出现在“执行”屏幕中。

Unchecking "Log uncaught exceptions to Cloud logs" is not working for me, but to my surprise logs do appear again in the execution log of the new IDE if the script is shared (view only is enough) with the user accessing the webapp.取消选中“Log uncaught exceptions to Cloud logs”对我不起作用,但令我惊讶的是,如果脚本与访问 web 应用程序的用户共享(仅查看就足够了),日志会再次出现在新 IDE 的执行日志中。 In case of using a doGet/doPost as a webhook endpoint, the script has to be shared with anyone with the link.如果使用doGet/doPost作为 webhook 端点,则必须与拥有链接的任何人共享该脚本。

Not sure whether this is a bug or by design, but cant see for the life of me the rationale of it.不确定这是错误还是设计使然,但我一生都看不到它的基本原理。

In addition to the above measures - also make sure that in the Logs Viewer you have selected Apps Script Function and the viewer is therefore not constrained to a different resource.除了上述措施 - 还要确保在日志查看器中您选择了Apps 脚本 Function ,因此查看器不会被限制到不同的资源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM