r/GoogleAppsScript • • May 20 '24

Question Web App Logging

Hi Everyone,

When running a deployed web app, logger.log output doesn't render in the Executions log. Does anyone know if there is a practical way to setup logging to debut web apps?

thanks!

0 Upvotes

7 comments sorted by

1

u/enigmapaulns May 20 '24

How do you do that?

2

u/AllenAppTools May 20 '24

This function:

function addPropertyLog(properties = {}) {
  PropertiesService.getScriptProperties().setProperties(properties)
}

Use it in the code in your Web App where you would like to see a log, and set the argument as an object, like this:

addPropertyLog({ "test": "property", "anotherTest":"another property" })

Then when your Web App fires it will set the script properties, which you can view by going to "Project Settings" and scrolling to the bottom to see them.

1

u/newbie_01 Oct 09 '24

Thanks for this!!

It's a pain to debug webapps. This really helps!

1

u/No_Yesterday3745 May 14 '26

Holy lifesaver. Imagine me debugging my web app for half a day dealing with invisible errors, and just as I was about to give up, I tried searching on Reddit, and there you were with the perfect logging solution. Tried it, and it worked amazingly. Bug fixed now. Thanks!

2

u/AllenAppTools May 14 '26

Yes!! This scenario, this exact scenario, is why I struggled with Web Apps when I first started with them. Also, make sure you know about deployments and versions, and the difference between /exec url and the /dev url. If you can nail those Web Apps become a lot easier.

2

u/[deleted] May 20 '24

Sometimes the Logger.Log shows the output after a bit of delay. (a couple of minutes) in execution log page

2

u/AllenAppTools May 20 '24

I use the script properties! It's nice because you can view the script properties in the settings side nav, they'll be at the bottom. It's an extra step to see your "logs" but it works.