简体   繁体   English

使 PHP 错误日志可供 CloudWatch 和日志包使用

[英]Make PHP error logs available to CloudWatch and logs bundle

I have a PHP environment in my ElasticBeanstalk application.我的 ElasticBeanstalk 应用程序中有一个 PHP 环境。 I receive a HTTP 500 error at some point and I am unable to debug it as I don't see any log of it in the logs bundle.我在某个时候收到 HTTP 500 错误,我无法调试它,因为我在日志包中看不到它的任何日志。 My environment is configured to stream logs to CloudWatch and still nothing about the 500 error.我的环境配置为 stream 记录到 CloudWatch,但仍然没有关于 500 错误的信息。

I tried adding a configuration file to the .ebextensions directory:我尝试将配置文件添加到.ebextensions目录:

files:
  "/opt/elasticbeanstalk/tasks/bundlelogs.d/php.conf":
    mode: "000755"
    owner: root
    group: root
    content: |
      /var/log/php/*
      /var/log/php-fpm/*

But still there is no php log file in the logs bundle.但是日志包中仍然没有 php 日志文件。 What can I do about this?我该怎么办? Thanks.谢谢。

IF you are using a php framework, most of them are configured to intercept and handle errors, so they don't show up in standard logs. 如果您使用的是php框架,则其中大多数都配置为拦截和处理错误,因此它们不会显示在标准日志中。

For Laravel, you would need to make sure you have logging enabled, and either set or use the default log location, and then add that location to your configuration. 对于Laravel,您需要确保已启用日志记录,并设置或使用默认日志位置,然后将该位置添加到配置中。

See Where are logs located? 请参阅日志位于何处? for more information on logging. 有关日志的更多信息。

The following is not tested, but should hopefully do the trick.以下内容未经测试,但应该可以解决问题。

We should first start with finding where exactly the logs are located (see Where are logs located? ).我们应该首先从查找日志的确切位置开始(请参阅日志位于何处? )。 Once we identify that, we note the following (from the AWS docs ):一旦我们确定了这一点,我们就会注意到以下内容(来自 AWS 文档):

The Elastic Beanstalk integration with CloudWatch Logs doesn't directly support the streaming of custom log files that your application generates. Elastic Beanstalk 与 CloudWatch Logs 的集成不直接支持流式传输您的应用程序生成的自定义日志文件。 To stream custom logs, use a configuration file to directly install the CloudWatch Logs agent and to configure the files to be pushed. stream自定义日志,使用配置文件直接安装CloudWatch Logs代理,配置推送的文件。

Example configuration also given in the docs can be found here .可以在此处找到文档中也给出的示例配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM