Reputation: 1399
I'm trying to see output of a script, but when I go to "View Logs" I get an alert "No logs found. Use Logger API to add logs to your project."
How do I add the Logger API?
Upvotes: 14
Views: 12803
Reputation: 31300
In order to use Logger.log()
you don't need to add anything or do any set up.
If you are using Logger.log('something here')
but nothing printed to the log, the main reason for that would be that your code failed before a Logger.log()
line ran. The first thing you should do is check the Execution Transcript. Under the View menu, choose Execution Transcript. Look for an error. If there is an error, then it will give an error message an the line where the error occurred.
If you want to use Stackdriver, which uses console.log()
that's a little bit different.
Under the View menu, you will see a menu item for: Stackdriver logging If you choose that, you will be taken to the Google Cloud Platform if you have a GCP project set up and associated with the Apps Script project. If you don't have a GCP project set up and associated with the Apps Script project, you can still see your console.log() print out in your Apps Script Dashboard executions.
https://script.google.com/home/executions
Use the above link, or right click the icon in the upper left of the code editor, and open in a new tab.
Apps Script Documentation - Logging Requirements
Upvotes: 3
Reputation: 1595
You will want to add into your code
Logger.log("Yes, this was logged");
Also reference this page for more info: https://developers.google.com/apps-script/reference/base/logger
Upvotes: 1