General

How to Enable Magento Error Logs In Magento 2

Hello Magento Folks,

How are you all today?. I have come along to give you some rich knowledge about the interesting topic of Magento 2: How to Enable Error Reporting. If you are looking for a Responsive Magento Theme for your Magento 2 Store then kindly take a visit to the previous article of the Magento Tutorial series Top 10 Best Responsive Magento Themes for 2021

Enable Magento Error Logs In Magento 2

If you are facing a problem in which your Magento store displays a plain white page, a blank page with the error numbers, 500 Internal servers or any broken content error with missing footer then to overcome this problem apply the below-given steps on your Magento 2 Store.

One of the most used Ecommerce platforms Magento has functionality that it shows the error message in various forms based on its server settings whether it is in developer mode or in production mode. If you are busy debugging any type of issue on your Magento 2 store then better is to set it in developer mode for not facing any type of inconvenience.

Enable error reporting: Displays Blank White Page.

Mainly the reason behind this is most probably the issue coming in fatal PHP error that means the PHP is not able to recover and due to the purpose of security, most of the servers are configured to hide the error message by default because it includes sensitive information. The smooth and easiest method to debug a blank page error is to get through the reason due to which issue is created.

Step 1: Firstly, you have to verify your PHP logs by connecting to your server with the help of SSH or using the c panel file. If this is not possible then you can easily contact your server hosting partner by describing the issue and generating the ticket for getting the access for your error log files.

Step 2: If there is no access to your server or you find difficulties in finding the location then you can forcefully print the error message to your browser with the help of editing your index.php file as illustrated below.

error_reporting(E_ALL);
 ini_set('display_errors', 1);

Eg. index.php

<?php
 ...
  error_reporting(E_ALL);
  ini_set('display_errors', 1);
 
 try {
     require DIR . '/app/bootstrap.php';
 } catch (\Exception $e) { ...... }

For not displaying the sensitive information to your users, one can directly hard code their IP address so only the error message will only be displayed to the configured IP address.

 $customIPAddress = ['your IP address here'];
 
 if (in_array($_SERVER["REMOTE_ADDR"], $customIPAddress) {
 
  error_reporting(E_ALL);
  ini_set('display_errors', 1);
 
 }

Enable error reporting: Displays Blank White Page With Error Message

Step: For the error displayed above you can easily perform by visiting ssh into your web server, and can navigate to your Magento 2 root folder/var/report then read the file name and view the error message respectively. 

Enable error reporting: Broken Content with Missing Footer

When there is any issue regarding the content of the page then automatically PHP encounters the error and the PHP stops working. To overcome this you have to firstly open the debug view on your browser and after that scroll down and verify whether there is any error information displayed or not. If the error is not displayed then you have to enable the option of error reporting and try again.

Step 1: Check php error / apache / NGINX error log files in the /var/log/ folder

Step 2: Check your Magento 2 error folder in Magento root var folder (var/report/*, var/log/debug.log, var/: exception.log and system.log)

Step 3: Check your Magento mode (default, developer or production)

Step 4: Check your server php error log setting

Final Words

Therefore, by implementing the above-given steps, you will be able to successfully enable the error reporting in Magento 2. If you find any difficulties in implementing the above-given steps then you can feel free to contact our Support Team who will guide you regarding this.

If you find the article is full of rich knowledge then do share with your Magento friends and comment down your views regarding the article. Also, comment down if you want me to solve any problems you are facing. Till then stay home and stay safe.

Happy Reading

Click to rate this post!
[Total: 7 Average: 2.6]
Gaurav Jain

Gaurav Jain is Co-Founder and Adobe Certified Expert-Magento Commerce Business Practitioner. Being Computer Engineer👨‍💻 and possessing Extensive Marketing skills he handles all kinds of customer Queries and his Happy😀 & Helping🙏 Nature makes customer's day Delightful. When he isn’t working, you’ll find Gaurav Reading on Books📖 or Traveling🚗. Also, he is Speaker at Magento Meetups.

View Comments

  • I have a question If I am in production envirment so can i see my error inside the var/report folder ?

Recent Posts

Magento 2: Add Quantity Increment and Decrement on Category Page

Hello Magento Friends, In this blog, we will discuss about adding quantity increment and decrement…

7 hours ago

How to Integrate ChatGPT with Laravel Application?

In this guide, we'll explore how to integrate ChatGPT, an AI-powered chatbot, with a Laravel…

3 days ago

What are Net Sales? How to Calculate Your Net Sales?

In the world of business, understanding financial metrics is crucial for making informed decisions and…

6 days ago

Magento 2 Extensions Digest April 2024 (New Release & Updates)

Welcome to the MageComp Monthly Digest, where we bring you the latest updates, releases, and…

6 days ago

The ABCs of Geofencing: Definition, Features and Uses

In this era, businesses are always on the lookout for ways to engage with their…

6 days ago

How to Delete Product Variant in a Shopify Remix App using GraphQL Mutations?

Managing a Shopify store efficiently involves keeping your product catalog organized. This includes removing outdated…

1 week ago