2
votes

I have created a google apps script to be a web app and to interact with a spreadsheet. It is currently attached to a spreadsheet (which I created) which currently resides in a shared drive. I discovered that stackdriver logging, which I used previously and has worked well (Logger.log) on other projects a while ago (I think before the change to where default projects no longer support stackdriver logging). I use a lot of time-based triggers, so if there's an error I would like to have that log history available. Right now, I have to run the function again in the GAS editor and view the logs immediately after execution.

I followed the instructions to create a new Google Cloud Project and tried to associate the GAS project with the new standard GCP project by entering the number in the Cloud Platform project... menu item, but I get an error that the Project does not exist or you need edit access to it. I just created the project yesterday in the Google Cloud Console, it definitely exists, the project number is the same as what I entered, and I am definitely the owner, so I have no clue why I'm getting this error.

I'm also asking whether this is the correct option. My account will be deleted from the organization within a year, but this script will still be in use after the fact (hence the shared drive). Should I even be making a Google Cloud Project, and is there a way to associate a Google Cloud Project with a shared drive so it will remain after my account disappears?

I did find a similar question: How to associate a Team Drive Apps Script with a GCP project?, but I don't think this is a duplicate, and that question also has no accepted answer. My ultimate question is How do I access Stackdriver Logging for a Google Apps Script in a Shared (Team) Drive?. Given the Google documentation on the issue, I need a standard GCP project. However, I would like to know if a standard GCP project is able to be owned by a shared drive, if so, how, and if not, then why am I getting the error message I'm getting?

Let me know if there's any more information you need. I hope I have explained the question well.

Apps Script Cloud Platform project Settings Cloud Platform project identification

1
Are these the instructions you followed? Since Stackdriver Logging is a GCP product its usage in GAS is a bit limited. Have you considered alternatives? like using and storing regular logs from the scripts' executions.AMolina
No. I did not see those. I had thought you had to use Logger.log to log from an apps script. Should I just be able to use console.log and they'll show up in the execution log? I'll try soon, but it'll take me a little while to test.Gregory Ling
Yes! I didn't know the difference between console.log and Logger.log. If you want to put that as an answer, I'll accept it. Console.log shows up in stack driver.Gregory Ling

1 Answers

2
votes

Posting for documentation purposes.

Are these the instructions you followed? Since Stackdriver Logging is a GCP product its usage in GAS is a bit limited. Have you considered alternatives? like using and storing regular logs from the scripts' executions.

In Apps Scripts, you use Logger instead of console because the scripts run in the server, so you don't really have a console to write to locally.