Logging 我是否可以将自定义日志文件添加到elastic beanstalk';s';电子商务日志';指挥部?

Logging 我是否可以将自定义日志文件添加到elastic beanstalk';s';电子商务日志';指挥部?,logging,amazon-web-services,amazon-elastic-beanstalk,Logging,Amazon Web Services,Amazon Elastic Beanstalk,当我通过web界面或“eb logs”请求弹性beanstalk环境的日志文件时,我会得到日志文件/var/log/eb-version-deployment.log、/opt/python/log/httpd.out、/var/log/cfn-hup.log和其他几个文件的内容 是否有办法将其他日志(如test_output.log)添加到web界面收集的日志和“eb日志”?是!有办法。您永远不必ssh到Elastic Beanstalk实例中 我们通过检查eb activity.log文件找

当我通过web界面或“eb logs”请求弹性beanstalk环境的日志文件时,我会得到日志文件/var/log/eb-version-deployment.log、/opt/python/log/httpd.out、/var/log/cfn-hup.log和其他几个文件的内容


是否有办法将其他日志(如test_output.log)添加到web界面收集的日志和“eb日志”?

是!有办法。您永远不必ssh到Elastic Beanstalk实例中

我们通过检查
eb activity.log
文件找到了答案

根据您的环境类型(我使用Beanstalk中的Python),可以放置日志文件的位置会有所不同。您需要检查
eb activity.log

例如,对于Python环境类型,在
eb activity.log
中,您应该看到:

[2015-09-15T20:29:36.102Z] INFO  [2403]  - [Initialization/PreInitStage0/PreInitHook/01setuplogs.sh] : Completed activity. Result:
  + mkdir -p /opt/elasticbeanstalk/tasks/taillogs.d /opt/elasticbeanstalk/tasks/sytemtaillogs.d /opt/elasticbeanstalk/tasks/bundlelogs.d /opt/elasticbeanstalk/tasks/publishlogs.d
  + /opt/elasticbeanstalk/bin/log-conf -n python '-l/opt/python/log/*' -t taillogs,systemtaillogs,bundlelogs
  + /opt/elasticbeanstalk/bin/log-conf -n python-app '-l/opt/python/log/app.out.*' -t publishlogs
  + /opt/elasticbeanstalk/bin/log-conf -n supervisord '-l/opt/python/log/supervisord.log.*' -t publishlogs
  + /opt/elasticbeanstalk/bin/log-conf -nhttpd '-l/var/log/httpd/*' -f /opt/elasticbeanstalk/containerfiles/beanstalkhttpd
上面显示Beanstalk为以下任何文件配置日志记录:

  • /opt/python/log/*
  • /opt/python/log/app.out*
  • /opt/python/log/supervisord.log*
  • /var/log/httpd/*

也就是说,如果您将日志文件放在
/opt/python/log/
中,Beanstalk将在您“请求日志”时找到并显示它。我将日志文件放在
/opt/python/log/
中,因为WSGI组(运行我的应用程序)可以访问它。顺便说一下,如果您使用的是Ruby环境类型,这将略有不同。您仍然可以检查
eb activity.log
为哪些目录设置了日志记录。

Elastic Beanstalk在此文件夹中查找有关跟踪哪些日志的配置文件:

/opt/elasticbeanstalk/tasks/taillogs.d/
在我的盒子上有一些文件

[ec2-user@ip taillogs.d]$ ls -al
total 32
drwxr-xr-x 2 root root 4096 Sep 27 05:49 .
drwxr-xr-x 6 root root 4096 Sep 27 05:49 ..
-rw-r--r-- 1 root root   58 Sep 27 05:49 eb-activity.conf
-rw-r--r-- 1 root root   35 Sep 27 05:49 eb-version-deployment.conf
-rw-r--r-- 1 root root   16 Oct 15 03:44 httpd.conf
-rw-r--r-- 1 root root   16 Oct 15 03:44 nginx.conf
-rw-r--r-- 1 root root   26 Oct 15 03:44 nodejs.conf
-rw-r--r-- 1 root root   29 Oct 15 03:44 npm.conf
每个都有一行,就像这样:

/var/log/nodejs/nodejs.log

使用
.ebextensions
添加配置文件以跟踪您自己的日志:

files:
  "/opt/elasticbeanstalk/tasks/taillogs.d/my-app-logs.conf":
    mode: "000755"
    owner: root
    group: root
    content: |
      /var/log/my-app.log
更多信息请点击此处:


您好,我们可以使用此命令从elastic beanstalk中的docker容器中检索django日志文件吗?我现在可以使用命令行
eb logs
查看结果日志,但在CloudWatch web UI中还看不到它。有什么建议吗?谢谢如果您将日志文件写入
/opt/python/log
文件夹,它将自动包括在内。这也是这位官员所做的。如果遇到
许可错误
,请参阅(可能的)说明。
files:
  "/opt/elasticbeanstalk/tasks/taillogs.d/my-app-logs.conf":
    mode: "000755"
    owner: root
    group: root
    content: |
      /var/log/my-app.log