如何在 Microsoft Azure 上的 Python WebJob 中打印到控制台?
How to print to console in a Python WebJob on Microsoft Azure?
如何将调试信息从 Python 脚本打印到 Azure WebJob 控制台?
我已经成功deployed a continuously running Python WebJob on Microsoft Azure, I have included my packages, and when the console showed some errors I've been able to fix them and re-upload through FTP.
现在,控制台(Azure WebJobs 仪表板)显示我的脚本是 运行。
[10/29/2015 10:42:53 > a19167: SYS INFO] Status changed to Starting
[10/29/2015 10:42:53 > a19167: SYS INFO] Job directory change detected: Job file 'run.py' timestamp differs between source and working directories.
[10/29/2015 10:42:58 > a19167: SYS INFO] Run script 'run.py' with script host - 'PythonScriptHost'
[10/29/2015 10:42:58 > a19167: SYS INFO] Status changed to Running
但是,我的脚本中充斥着 print()
未显示的语句。我也试过 sys.stdout.write()
和 sys.stderr.write()
但它们也不起作用。
更新:打印消息显示!它们只是成批出现,每隔几个小时出现一次...
要立即在 Azure WebJobs 仪表板中查看您的日志语句,只需调用 sys.stdout.flush()
初始化 Web 作业和处理单个任务(例如处理队列消息)后刷新控制台输出是有意义的。
如何将调试信息从 Python 脚本打印到 Azure WebJob 控制台?
我已经成功deployed a continuously running Python WebJob on Microsoft Azure, I have included my packages, and when the console showed some errors I've been able to fix them and re-upload through FTP.
现在,控制台(Azure WebJobs 仪表板)显示我的脚本是 运行。
[10/29/2015 10:42:53 > a19167: SYS INFO] Status changed to Starting
[10/29/2015 10:42:53 > a19167: SYS INFO] Job directory change detected: Job file 'run.py' timestamp differs between source and working directories.
[10/29/2015 10:42:58 > a19167: SYS INFO] Run script 'run.py' with script host - 'PythonScriptHost'
[10/29/2015 10:42:58 > a19167: SYS INFO] Status changed to Running
但是,我的脚本中充斥着 print()
未显示的语句。我也试过 sys.stdout.write()
和 sys.stderr.write()
但它们也不起作用。
更新:打印消息显示!它们只是成批出现,每隔几个小时出现一次...
要立即在 Azure WebJobs 仪表板中查看您的日志语句,只需调用 sys.stdout.flush()
初始化 Web 作业和处理单个任务(例如处理队列消息)后刷新控制台输出是有意义的。