Skip to content

Add WooCommerce logs to AWS Beanstalk

In order to run a high performant and scaling WordPress site including WooCommerce Elastic Beanstalk in combination with RDS is a good way to go.

In an upcoming tutorial I will cover how you’ll setup a WordPress site on AWS Beanstalk. If you’ve already setup your site you might come across the problem that you want to access custom log files including the ones that are produced by WooCommerce and it’s various payment gateways.

When working with Beanstalk you should never SSH into the underlying EC2 instance to access log files or similar stuff. AWS provides you with a way to access all logs through the Dashboard. By default the Apache and PHP log files are included in what the dashboard collects.

AWS Beanstalk logs files for WordPress & WooCommerce

Let’s go ahead now and add the custom logs to Beanstalk.

1. Retrieve WooCommerce Log Path

The default log path for WooCommerce on Elastic Beanstalk should be:

/var/app/current/wp-content/uploads/wc-logs/*

Make sure your path is the same by opening the WordPress admin panel and then

WooCommerce -> Settings -> PayPal

This will show you the log path of the PayPal payment gateway, which logs into the same folder as WooCommerce.

Retrieve WooCommerce Log Path

2. Add Path to Beanstalk log tasks

In order to add the logs of WooCommerce to Beanstalk you need to add a config file in .ebextensions  to your project

If you don’t have the .ebextensions folder already in your project, go ahead an create it now.

Now in the .ebextensions  folder create a new file and name it wc-logs.config . Add the following content to the file:

#####################################################
#### Adds WooCommerce log files to Beanstalk log ####
#####################################################

files:
  # Add WooCommerce logs to tail logs
  "/opt/elasticbeanstalk/tasks/taillogs.d/wc-logs.config" :
    mode: "000755"
    owner: root
    group: root
    content: |
      /var/app/current/wp-content/uploads/wc-logs/*.log
  # Add WooCommerce logs to bundle logs
  "/opt/elasticbeanstalk/tasks/bundlelogs.d/wc-logs.config" :
    mode: "000755"
    owner: root
    group: root
    content: |
      /var/app/current/wp-content/uploads/wc-logs/*.log

This YAML file tells Beanstalk to add the directory where all WooCommerce log files are to the bundle logs and the tail logs.

The Bundle logs contain all log files, whereas the tail log only contains the last 100 lines of the log files.

If your log path was different from the default path in step 1, adjust it accordingly.

3. Deploy your updated app

Now save everything and deploy your app to Elastic Beanstalk. All your WooCommerce logs should now being collected through the AWS Beanstalk log task.

Happy logging 😉

Published inDevOps

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *