gpt4 book ai didi

python - Azure 应用服务上的 Python 本地日志在哪里?

转载 作者:行者123 更新时间:2023-12-02 08:30:56 25 4
gpt4 key购买 nike

如果我在本地运行,我可以看到我的 print() 文本。但即使启用文件系统应用服务日志后,我仍然在 _docker.log 或流日志中看不到任何日志。在 Azure 应用服务上为 Python 生成本地日志的正确方法是什么?

最佳答案

为了关闭循环,我最终制作了一个简单的日志方法

def writeLog(log: str):
basepath = path.dirname(__file__)
today = date.today()
filepath = path.abspath(path.join(basepath, "..", "..", "LogFiles", "MyBot_" + today.strftime("%Y-%m-%d") + ".log"))
f = open(filepath, "a+")
f.write(today.strftime("%Y-%m-%d %H:%M:%S") + " " + log)
f.write("\n")
f.close()

如果我不close(),我将无法下载该文件。将其与其他日志文件一起放在 LogFiles 中,可以更轻松地从 VS Code 中查看

关于python - Azure 应用服务上的 Python 本地日志在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61091884/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com