0

I'm running a PHP web app on AWS Elastic Beanstalk, and I've been trying to diagnose some seemingly random (rare) issues users have been encountering after upgrading to PHP 8.

On localhost, I'd have error reporting on for diagnostics, but in production that is disabled (for security reasons), but I'd still like to be able have PHP server errors logged and accessible for me to download.

Elastic Beanstalk allows me to download full logs or the last 100 lines. But neither include PHP errors or warnings. I don't really need them pushed to CloudWatch, just need to be able to access them easily from the AWS EB Console. (I only run one EC2 instance for the application, but don't want to SSH or such into the server.)

If I check PHP info, it's set to Log Errors, and gives the log location:

log location

errors on

I can place config files in the .ebextensions folder of the application, but I can't seem to get it to include PHP logs in the last 100 lines or the zipped log file package I can download from the console.

1
  • I'd suggest you use the Cloudwatch Logs agent to push the logs to CW logs.
    – Tim
    Feb 17, 2022 at 7:04

1 Answer 1

1

You can use configuration files to configure your environment to attach custom logs to the existing tailed logs.

You can add AWS Elastic Beanstalk configuration files (.ebextensions) to your web application's source code to configure your environment and customize the AWS resources that it contains. Configuration files are YAML- or JSON-formatted documents with a .config file extension that you place in a folder named .ebextensions and deploy in your application source bundle.

Create a new config file e.g server-logs.config

Define the following in the config file to include the server error logs in your app.

files:
 "/opt/elasticbeanstalk/tasks/taillogs.d/app_error.conf" :
    mode: "000755"
    owner: root
    group: root
    content: |
      /var/log/php-fpm/www-error.log

The server logs will show below this line the next time you request new logs

----------------------------------------
/var/log/php-fpm/www-error.log
----------------------------------------
1
  • thanks a bunch; this worked to add the PHP error logs to the "last 100 lines" on the EB logs.
    – Ben in CA
    Dec 24, 2022 at 17:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .