1

I have a PHP environment in my ElasticBeanstalk application. 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. My environment is configured to stream logs to CloudWatch and still nothing about the 500 error.

I tried adding a configuration file to the .ebextensions directory:

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. What can I do about this? Thanks.

Victor
  • 13,914
  • 19
  • 78
  • 147
  • Some php frameworks will install error handlers and manage the log. Are you doing pure php, or using a framework (like cake, yii, etc)? – chris Apr 02 '18 at 22:45
  • I am using Laravel, but still the HTTP response from the request is 500. Shouldn't Apache/PHP know about that? – Victor Apr 03 '18 at 07:35
  • Did you ever figure this out? I'm looking for the same thing. – Ben in CA Feb 11 '22 at 15:54
  • @BeninCA did some quick research now and put an naswer here. Hope it helps. I can't reproduce the setup easily, but I hope you can try it out. – Victor Feb 12 '22 at 08:40
  • @Victor - my question is similar https://serverfault.com/questions/1093921/access-php-error-log-in-aws-elastic-beanstalk Unfortunately your answer didn't help yet. – Ben in CA Feb 16 '22 at 23:06
  • You most likely cannot access any file directly. I would say try to publish to CloudWatch logs to gain the visibility. Or maybe that’s not what you’re asking? – Victor Feb 17 '22 at 05:59

2 Answers2

0

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.

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.

See Where are logs located? for more information on logging.

chris
  • 36,094
  • 53
  • 157
  • 237
  • Since I am using Elastic Beanstalk, how can I instruct the system to pick logs from my application folder? Where is my app located? – Victor Apr 03 '18 at 18:59
0

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):

The Elastic Beanstalk integration with CloudWatch Logs doesn't directly support the streaming of custom log files that your application generates. To stream custom logs, use a configuration file to directly install the CloudWatch Logs agent and to configure the files to be pushed.

Example configuration also given in the docs can be found here.

Victor
  • 13,914
  • 19
  • 78
  • 147