我如何“使用Logger API将日志添加到您的项目中"?(Google脚本) [英] How do I "Use Logger API to add logs to your project"? (Google Script)

查看:68
本文介绍了我如何“使用Logger API将日志添加到您的项目中"?(Google脚本)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试查看脚本的输出,但是当我转到查看日志"时,收到警报找不到日志.使用Logger API将日志添加到您的项目中."

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."

如何添加Logger API?

How do I add the Logger API?

推荐答案

要使用 Logger.log(),您无需添加任何内容或进行任何设置.

In order to use Logger.log() you don't need to add anything or do any set up.

如果您使用的是 Logger.log('something here'),但没有打印到日志,则主要原因是您的代码在 Logger.log()行.您应该做的第一件事是检查执行记录.在视图菜单下,选择执行记录.寻找错误.如果有错误,则会在发生错误的行上显示一条错误消息.

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.

如果您想使用Stackdriver,它使用的 console.log()有点不同.

If you want to use Stackdriver, which uses console.log() that's a little bit different.

在查看"菜单下,您将看到以下菜单项:Stackdriver记录如果您选择该选项,则如果您设置了GCP项目并将其与Apps Script项目相关联,则会被带到Google Cloud Platform.如果您尚未设置GCP项目并与Apps Script项目相关联,则仍可以在Apps脚本仪表板执行中看到console.log()打印出来.

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.

应用脚本文档-记录要求

这篇关于我如何“使用Logger API将日志添加到您的项目中"?(Google脚本)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆