19

Apps Script has recently moved the StackDriver logs into the Apps Script dashboard, page 'Execution'.

Problem is, the logs won't show up in the dashboard for Apps Script web apps. 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.

I'm using the Stackdriver Logging:

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').

Also, it works with GET requests, but not with POST requests.

The web app is deployed with the permissions below:

  • Execute the app as 'Me'
  • Who can access to the app: anyone, even anonymous
  • Drive sharing settings: only specific people can access

enter image description here

Is it a bug in their new interface or am I missing something?

TheMaster
  • 45,448
  • 6
  • 62
  • 85
lordofmax
  • 773
  • 1
  • 7
  • 21
  • 1
    Possibly bug.... – TheMaster Jun 03 '19 at 19:55
  • 2
    I believe you can only see logs if you ran the app from within the project. Or maybe you can’t see logs if the request was from an anonymous user – Brandon Aug 02 '19 at 17:32
  • 1
    having the same issue, quite certain this worked when the logs were showing in the regular stackdriver logging interface on the cloud console, but not getting logs for anonymous requests now that they are on script.google.com – Cameron Roberts Oct 01 '19 at 22:59

4 Answers4

2

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.

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.

Cameron Roberts
  • 7,127
  • 1
  • 20
  • 32
1

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. You should then find that logs re-appear in the "Executions" screen.

Ben
  • 7,548
  • 31
  • 45
  • thanks a lot for the guidelines. I think your method is the easiest possible so far for web-apps. Nevertheless, Google should do this as easy as viewing the Logs when we run the non-web-app script. They shouldn't make it so painful just for developers to view the logs. :( – dell Apr 26 '21 at 17:28
  • Unfortunately this didn't work for me either. After unchecking the "Log uncaught exceptions to Cloud logs" checkbox, I tried creating a new version of my web app deployment. That didn't work, so I archived my web app deployment and created a brand new web app deployment. That didn't work either. :( – bumbleshoot Oct 14 '21 at 07:43
0

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. In case of using a doGet/doPost as a webhook endpoint, the script has to be shared with anyone with the link.

Not sure whether this is a bug or by design, but cant see for the life of me the rationale of it.

0

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.

Dan Gravell
  • 7,855
  • 7
  • 41
  • 64