Python 3.x AWS Cloudwatch中未显示日志

Python 3.x AWS Cloudwatch中未显示日志,python-3.x,amazon-web-services,flask,logging,amazon-cloudwatch,Python 3.x,Amazon Web Services,Flask,Logging,Amazon Cloudwatch,我一直在尝试让AWS Cloudwatch的日志工作,但到目前为止都没有成功。我正在Fargate上运行python flask后端,并通过Cloudwatch处理日志记录。但是,只显示错误消息,与我插入的日志无关。我将在cloudwatch上获得错误消息和启动消息,但没有日志 * Serving Flask app "app" (lazy loading) * Environment: production WARNING: This is a developme

我一直在尝试让AWS Cloudwatch的日志工作,但到目前为止都没有成功。我正在Fargate上运行python flask后端,并通过Cloudwatch处理日志记录。但是,只显示错误消息,与我插入的日志无关。我将在cloudwatch上获得错误消息和启动消息,但没有日志

 * Serving Flask app "app" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: on
 * Restarting with windowsapi reloader
 * Debugger is active!
 * Debugger PIN: 222-692-161
 * Running on http://0.0.0.0:6000/ (Press CTRL+C to quit)

127.0.0.1 - - [03/Nov/2020 09:47:23] "GET /health HTTP/1.1" 200 -
这在Cloudwatch、烧瓶启动对话框和消息中显示,healthcheck查询工作正常/但是我的healthcheck中没有日志。我尝试了两种策略

  • 日志库
  • 我还定义了一个打印函数将数据发送到stderr,这样我就可以让cloudwatch接收数据

    
    def eprint(cls, *args, **kwargs):
        print(*args, file=sys.stderr, **kwargs)
    eprint("this is another informative log")
    
    我不知道为什么这两种解决方案都不起作用,因为Cloudwatch应该接收发送到stderr的数据。有没有一种方法可以在几行代码中启用Cloudwatch日志,并且尽可能少地侵入

    提前谢谢你

    
    def eprint(cls, *args, **kwargs):
        print(*args, file=sys.stderr, **kwargs)
    eprint("this is another informative log")