我可以将自定义日志文件添加到弹性beanstalk的'eb logs'命令捕获的日志中吗?

use*_*678 19 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日志"收集的日志中?

Sam*_*eff 23

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

/opt/elasticbeanstalk/tasks/taillogs.d/
Run Code Online (Sandbox Code Playgroud)

在我的盒子上有一些文件

[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
Run Code Online (Sandbox Code Playgroud)

每个人都有一行,像这样:

/var/log/nodejs/nodejs.log
Run Code Online (Sandbox Code Playgroud)

要么

/var/log/nginx/*
Run Code Online (Sandbox Code Playgroud)

使用.ebextensions的配置文件添加到尾自己的日志:

files:
  "/opt/elasticbeanstalk/tasks/taillogs.d/my-app-logs.conf":
    mode: "000755"
    owner: root
    group: root
    content: |
      /var/log/my-app.log
Run Code Online (Sandbox Code Playgroud)

更多信息:

http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.logging.html#health-logs-extend


Mik*_*ike 4

是的!有一种方法。您永远不必通过 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
Run Code Online (Sandbox Code Playgroud)

上面显示 Beanstalk 为以下任意文件配置日志记录:

  • /opt/python/日志/*
  • /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为日志记录设置了哪些目录。