记录仪日志自动清除 [英] Logger log cleared automatically

查看:122
本文介绍了记录仪日志自动清除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了此脚本以通过电子邮件发送日志,类似于 https://developers.google.com/apps-script/reference/base/logger# 用户可以使用报告问题"菜单项. 但是,似乎每次执行菜单项都会清除日志. 有没有解决的办法?如果不是,那么每次运行函数时都清除日志系统的目的是什么?

I created this script to send logs by email, similar to the example on https://developers.google.com/apps-script/reference/base/logger# A "Report problem" menu item is available to the users. However, seems like everytime a menu item is executed the log is cleared. Is there a way around this? If not, what is the purpose of having a logging system if it is cleared everytime a function is ran?

推荐答案

该日志用于调试.这个想法是,一旦您运行了函数,您就已经在脚本编辑器中了,您可以看看问题出在哪里.

The log is for debugging purposes. The idea is that once you run the function you are already in the script editor and you can just look at what went wrong.

要解决此问题,您可以让正在记录的脚本使用getLog()检索为字符串并将其输出到用户Google云端硬盘上的文件中.然后,我们的报告问题"脚本会获取该文件并将其发送过来.

To get around this, you can have the script that you are logging use getLog() to retrieve it as string and output the string into a file on the users Google Drive. YOur "Report Problem" script then takes that file and sends it over.

这是日志以我所知道的每种编程语言工作的方式.再次启动程序时,除非将其写入文件,否则它将被丢弃并从头开始.这也正是您要做的.

This is the way logs work in every programming language that I know. It is discarded and started from scratch when you start the program again unless you write it to a file. That is exactly what you have to do here as well.

您还可以在此处查看历史日志: https://console.cloud.google.com StackDriver → Logging → Logs

you can also view historical logs here: https://console.cloud.google.com under StackDriver → Logging → Logs

这篇关于记录仪日志自动清除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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