Magento error logs and debugging.
18 August 2019
Article explains how to use Magento and Apache error logs to debug or find issues in your installation.
It’s a good practice to check your error logs once a while. If you are still developing the site, turn on Magento developer mode
bin/magento deploy:mode:set developer
Magento error logs & reports
Depending on error type, Magento write it’s errors in several places. It’s important to know what these locations are, so you can easily debug the errors.
In Magento you need to turn on log write, so system start recording logs.
You need to go to Admin -> Configuration -> Advanced -> Developer -> Log setting
And Enable log settings. Keep the default files as it is.
Error Logs.
var/log folder contains the common log files along with error logs for your Magento 3rd party modules .
Magento system log file (system.log) and exception log files(exception.log) are saved to this folder unless you rename it from administrator configuration with different names.
Reading Error Files
To read your error logs, open it in your favorite editor.
Your error log file contains the following format
[error time] main.error_type error_description
Let’s look at few rows of system.log file
[2016-08-11 23:05:22] main.INFO: Add of item with id Magento_User::system_acl was processed [] []
[2016-08-11 23:50:27] main.INFO: Cache file with merged layout: LAYOUT_frontend_STORE1_40a98983867a1770682b48d9a0ad63441 and handles 1column: Please correct the XML data and try again. [] []
First line is a information log, set in Magento Backend module. This will indicate that Menu item is added to backend menu.
$this->_logger->info(
sprintf('Add of item with id %s was processed', $item->getId())
);
You need to focus on error type and error description. Error type indicates whether you need attention to a given error. Error description provides short description about a particular error.
Magento log system has several log levels;
- EMERGENCY
- CRITICAL
- ALERT
- ERROR
- WARNING
- NOTICE
- INFO
- DEBUG
It’s easy to follow the error time when debugging an issue. Check the time, a particular error happened and compare your logs for that particular time. Most of the errors can debug from your Magento log files.
Error Reports.
There has been an error processing your request
Exception printing is disabled by default for security reasons. By turning on developer mode you can view full details of the error.
Error log record number: 343443443351
We’ve all seen this error. All the critical exceptions will be written to var/report folder. You can find the error file by looking at the number. Error file for above example is 343443443351 and it doesn’t have any extension after it. You can open the file in you favorite editor.
Below is the first line of an error log file. Most often from the first line of the file you can find the error.
a:4:{i:0;s:86:"Class Forgeonline\Timeslotbooking\Model\Product\Attribute\BlockWeekdays does not exist";i:1;s:10460:"#0 /container/application/public/vendor/magento/framework/Code/Reader/ClassReader.php(19): ReflectionClass->__construct('Forgeonline\\Tim...')
Error describe of missing class file. This could be either missing class or Incorrect naming. To debug the error you need to double check the class file.
Apache Error Reports.
When it comes to errors and debugging them, we can not skip Apache error logs. You may need Apache error log access to debug some of the errors. Not all the errors are recorded to Magento logs.