How to Enable Error Logs in Magento 2?
Have you faced the frustration of encountering a blank white page, broken content, or 500 Internal server errors on your Magento platform? We understand these issues can be perplexing.
Don’t stress. We’ve got you covered.
In this blog, we’ll discuss the steps on how to enable error logs in Magento 2.
What is an Error Log in Magento 2?
Error log in Magento refers to a troubleshooting tool that stores error messages, notifications, and warnings.
These logs play an important role in fixing and debugging by giving details of the issues that may affect the functionality of the Magento 2 platform.
How to Enable Error Logs in Magento 2?
There are two ways to enable error logs in Magento 2. You can either do it from the admin dashboard or through the command line interface.
Let’s learn both methods.
Method 1: Enable Magento 2 Error Logs from Admin Panel
From Magento 2.4.x onwards, the platform automatically generates error logs and stores them in the var/log/debug.log file. Therefore, you can access them directly if you’re on the latest version.
And if you are using Magento 2.3.x or older versions, you need to manually enable error logs from the admin panel.
Here are the steps:
First and foremost, you need to log in to your Magento Admin Panel.
Step 1: Go to Stores > Configuration.
Step 2: Scroll to Advanced > Developer > Debug.
Step 3: Set “Log to File” to Yes and Save Configuration.
The debug details will be logged to the var/log/debug.log file. Flush the cache once if needed. Please note that the enabling error log is not possible if the production mode is active.
Method 2: Enable Magento 2 Error Logs Using CLI Command
For Magento 2.3.1 or above:
Run the following command in the Magento directory to enable the error log: bin/magento setup:config:set --enable-debug-logging=true
And flush the cache by running the following command: bin/magento cache:flush
For versions older than Magento 2.3.1:
The above command doesn’t work for Magento 2.3.1 and older versions. However, you can enable error reporting as follows:
enable: php bin/magento config:set dev/debug/debug_logging 1 && php bin/magento cache:flush
Final Words
Enabling the error logs in Magento 2 is an important step for effective troubleshooting. Whether you enable them through the Admin Panel or CLI commands, they help you to deliver a seamless experience.
I hope it is clear to you now how to enable error logs in Magento 2.
Explore the below resources to learn how to fix some other Magento 2 errors:
How to Fix Magento 2 Homepage 404 Error
Solved: Class Zend Not Found in Magento 2 – Fix All Zend Errors
Krupali Gohil
Krupali is a content writer at Meetanshi. She is an experienced writer who gives words life and loves writing content that makes a difference.
Prev
How to Add Social Media to Shopify (Step-By-Step)
Magento vs WooCommerce – The Ultimate Comparison [2024]
Next