Python,Flask,Elasticbeanstalk日志记录

sm-*_*ure 8 logging amazon-web-services flask python-2.7 amazon-elastic-beanstalk

我正在尝试使用Elasticbeanstalk来部署Flask REST API.记录和应用程序在我的测试系统上没有问题.但是,我没有使用来自AWS控制台的请求日志从ebs实例获取日志.

阅读stackoverflow 文章和AWS 文档,但无法正确设置.

我的应用程序日志设置

logger = logging.getLogger(__name__)
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
logger.setLevel(logging.DEBUG)
handler = RotatingFileHandler('/opt/python/log/application.log', maxBytes=1024,backupCount=5)
handler.setFormatter(formatter)
application = Flask(__name__)
application.logger.addHandler(handler)
Run Code Online (Sandbox Code Playgroud)

用法:

logger.debug(email)
Run Code Online (Sandbox Code Playgroud)

.ebextensions中的配置文件(尝试使用和不使用)

files:
  "/opt/python/log/application.log" :
   mode: "000666"
   owner: ec2-user
   group: ec2-user
   content: |
      # Python log file
Run Code Online (Sandbox Code Playgroud)

当我请求最后100行日志时,除了我在ebextension配置中的内容部分中放置的内容之外没有日志.

-------------------------------------
/opt/python/log/application.log
-------------------------------------
# Python log file
Run Code Online (Sandbox Code Playgroud)

我错过了什么?