View and manage logs

Logs for Magento Commerce Cloud projects are useful for troubleshooting problems related to Magento Commerce Cloud build and deploy hooks, cloud services, and the Magento application.

You can view the logs from the file system, the project web UI, and the magento-cloud CLI.

  • File system—The /var/log system directory contains logs for all environments. The var/log/ Magento directory contains app-specific logs unique to a particular environment. You must use an SSH connection to access logs in a remote server environment. These directories are not shared between nodes in a cluster. In Pro Production and Staging environments, you must check the logs on each node.

  • Project web UI—You can see build and post-deploy log information in the environment messages list.

  • Magento Cloud CLI—You can view logs using the magento-cloud log command.

Manage log data

On Pro Production and Staging environments, use the New Relic Logs application integrated with your project to manage aggregated log data from all logs associated with your Magento Commerce Cloud project.

The New Relic Logs application provides a centralized log management dashboard to troubleshoot and monitor Magento Commerce Cloud Production and Staging environments. The dashboard also provides access to log data for Fastly CDN, Image Optimization, and Web application firewall (WAF) services. See New Relic services.

Log command

When you are logged into your Magento Commerce Cloud project, you can use the magento-cloud log CLI command to quickly view a specific log from the command line. If you do not specify a log name, you can choose a log from the response list.

magento-cloud log

Sample response:

Enter a number to choose a log:
  [0] access
  [1] app
  [2] cron
  [3] deploy
  [4] error
  [5] php.access
  [6] post-deploy

By default, the command displays the log from the Integration environment. For the Pro Staging logs, you need to specify the log location using the project ID.

magento-cloud log platform/<project_id>_stg/<log>

Build and Deploy logs

After pushing changes to your environment, you can review the logging from each hook in the var/log/cloud.log file. The log contains start and stop messages for each hook. In the following example, the messages are “Starting post-deploy.” and “Post-deploy is complete.

Check the timestamps on log entries to verify and locate the logs for a specific deployment. The following is a condensed example of log output that you can use for troubleshooting:

Re-deploying environment project-integration-ID
  Executing post deploy hook for service `mymagento`
    [2019-01-03 19:44:11] NOTICE: Starting post-deploy.
    [2019-01-03 19:44:11] INFO: Validating configuration
    [2019-01-03 19:44:11] INFO: End of validation
    [2019-01-03 19:44:11] INFO: Enable cron
    [2019-01-03 19:44:11] INFO: Create backup of important files.
    [2019-01-03 19:44:11] INFO: Backup /app/app/etc/env.php.bak for /app/app/etc/env.php was created.
    [2019-01-03 19:44:11] INFO: Backup /app/app/etc/config.php.bak for /app/app/etc/config.php was created.
    [2019-01-03 19:44:11] INFO: php ./bin/magento cache:flush --ansi --no-interaction
    [2019-01-03 19:44:32] INFO: Warming up failed:
    [2019-01-03 19:44:32] NOTICE: Post-deploy is complete.

When you configure your Cloud environment, you can set up log-based Slack and email notifications for build and deploy actions.

Error logs

Error and warning messages generated during the deployment process are written to both the var/log/cloud.log and the var/log/cloud.error.log files. The Cloud error log file contains only errors and warnings from the latest deployment. An empty file indicates a successful deployment with no errors. See Error message reference for ece-tools.

The following logs have a common location for all Cloud projects:

  • Deployment log: var/log/cloud.log
  • Last deployment error log: var/log/cloud.error.log
  • Debug log: var/log/debug.log
  • Exception log: var/log/exception.log
  • Reports: var/reports/

Though the cloud.log file contains feedback from each stage of the deployment process, logs from the deploy hook are unique to each environment. The environment-specific deploy log is in the following directories:

  • Starter and Pro Integration: /var/log/deploy.log
  • Pro Staging: /var/log/platform/<project_id>_stg/deploy.log
  • Pro Production: /var/log/platform/<project_id>/deploy.log

The value of <project_id> depends on the project ID and whether the environment is Staging or Production. For example, with a project ID of yw1unoukjcawe, the Staging environment user is yw1unoukjcawe_stg and the Production environment user is yw1unoukjcawe. Using that example, the deploy log is: /var/log/platform/yw1unoukjcawe_stg/deploy.log

The log for each deployment concatenates to the specific deploy.log file. The following example prints the deploy log in the terminal:

magento-cloud log deploy

Sample response:

Reading log file'deploy.log'

Error Output:
sh: 1: kill: No such process

[2019-09-09 09:00:00] NOTICE: Validating configuration

You can use the same CLI command to view a deploy log from the Staging environment:

magento-cloud log platform/<project_id>_stg/deploy

See the Error message reference for ece-tools to review errors that can occur during the build, deploy, and post-deploy stages.

Application logs

Similar to deploy logs, application logs are unique for each environment. For Pro Staging and Production environments, the Deploy, Post-deploy, and Cron logs are available only on the first node in the cluster.

The following table lists application log locations on each environment:

Log file Starter and Pro Integration Pro Staging Pro Production
Deploy log /var/log/deploy.log First node only:
First node only:
Post-deploy log /var/log/post_deploy.log First node only:
First node only:
Cron log /var/log/cron.log First node only:
First node only:
Nginx access log /var/log/access.log /var/log/platform/<project_id>_stg/access.log /var/log/platform/<project_id>/access.log
Nginx error log /var/log/error.log /var/log/platform/<project_id>_stg/error.log /var/log/platform/<project_id>/error.log
PHP access log /var/log/php.access.log /var/log/platform/<project_id>_stg/php.access.log /var/log/platform/<project_id>/php.access.log
PHP FPM log /var/log/app.log /var/log/platform/<project_id>_stg/php5-fpm.log /var/log/platform/<project_id>/php5-fpm.log

Service logs

Because each service runs in a separate container, the service logs are not available in the Integration environment. Magento Commerce Cloud provides access to the web server container in the Integration environment only. The following service log locations are for the Pro Production and Staging environments:

  • Redis log: /var/log/platform/<project_id>_stg/redis-server-<project_id>_stg.log
  • Elasticsearch log: /var/log/elasticsearch/elasticsearch.log
  • Mail log: /var/log/mail.log
  • MySQL error log: /var/log/mysql/mysql-error.log
  • MySQL slow log: /var/log/mysql/mysql-slow.log
  • RabbitMQ log: /var/log/rabbitmq/rabbit@host1.log

Log file locations in the scaled architecture depend on the node type. See Log locations in the Scaled architecture topic.