我已经将python3.7函数部署到了Google Cloud。以下语句设置了该函数的日志记录。如果我从命令行执行该功能,则preferreder_logs.log文件将存储在当前工作目录中。
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s',
datefmt='%m-%d %H:%M',
filename='recommender_logs.log',
filemode='w')
console = logging.StreamHandler()
console.setLevel(logging.DEBUG)
# set a format which is simpler for console use
formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
# tell the handler to use this format
console.setFormatter(formatter)
# add the handler to the root logger
logging.getLogger('').addHandler(console)
我需要知道,当我从google cloud控制台执行功能时,需要在此处设置此文件,以便功能日志文件将存储在该文件中。如果我未设置任何路径,则默认情况下将在哪里存储文件?
我可以在Logging console中查看日志,但除此之外,还有一个地方可以查看该文件,或者只能选择云存储桶?任何人都可以帮忙。
GCP中部署的每个功能都在单独的容器中运行,如果需要存储任何数据,则只有在/tmp
运行该容器的容器中它才能在目录中存储。
从计算,Cloud Shell或使用API部署都没有关系。您的函数文件系统与任何其他函数甚至其本身的另一个实例都是隔离的。
您以某种持久存储方式存储文件,例如,必须将其导出到GCP存储桶。看看这个Stack答案-这可能对您有用。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句