ElasticBeanstalk 中的 Flask 日志记录
我正在尝试为部署在 ElasticBeanstalk 中的 Flask 应用程序设置日志记录。
我有一个基本的日志记录,可以在我的控制台中打印内容。
但在 Beanstalk 中部署时,我看不到任何应用程序日志。
为了实现这一目标,是否需要设置任何特定的配置?
只是分享一个示例代码。
用户.py
import logging
class User(Resource):
def details(self):
user_info = "Hello"
logging.info(user_info)
I am trying to set up Logging for my Flask app which is deployed in ElasticBeanstalk.
I have a basic logging in place that prints stuff in my console.
But on deploying in Beanstalk, I am not able to see any of the application logs.
Is there any specific config that needs to be setup in order to achieve this?
Just sharing a sample code.
user.py
import logging
class User(Resource):
def details(self):
user_info = "Hello"
logging.info(user_info)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将配置文件添加到
.ebextensions
文件夹,该文件夹将应用程序的日志添加到 EB 自动下载的日志中。假设您的应用程序记录到 Flask 应用程序根目录中名为
logs
的文件夹,您将创建一个名为.ebextensions/logging.config
的文件,如下所示:(此处的官方文档略有不同: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.logging.html)
然后,部署后,您应该能够使用 GUI 来下拉日志。
You can add a config file to your
.ebextensions
folder that adds your application's logs to the logs that EB downloads automatically.Assuming that your application logs to a folder called
logs
in the Flask app root, you would make a file called.ebextensions/logging.config
that looks like this:(Which is a slight variation on the official documents here: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.logging.html)
Then, after you deploy, you should be able to use the GUI to pull down logs.