IntroductionMagento is so complex that minor and major issues can come your way as to store administrator, as well as bother your customers. These problems are difficult to track and analyze if you are not a Magento specialist. In this short article, we will take the basics you need to know about error logging in Magento to pieces, including examining the right files and tracking problems efficiently.
What is Magento Log & Why You Need ItWhen there is something is wrong with your store, but you are not able to determine the reason on your own from the first sight, Magento error log is your number one troubleshooting tool to understand the roots of the problems and then solving them. What is more, not keeping an eye on the log files of your store can also lead to actual performance issues in your store. For example, huge log files can influence loading speed. Log files are always getting bigger every time something happens in your store, and if you don’t clean them up from time to time, gigabytes of error log files are getting piled up on your server. There might be certain problems that Magento is guilty of, and you have probably encountered or will encounter at least one of them. You can face:
- Blank pages;
- Pages that load partially;
- Error screens;
- Blocks missing from the pages;
- Any other unexpected page behavior.
How to Enable Logging for My Magento Store?In Magento 2 logging is enabled by default. To enable logging in Magento 1, the setting you need is located under System > Configuration > Advanced > Developer > Log Settings. The files system.log and exception.log will be created under MAGENTO/var/log/ once any error occurs. PHP warnings and errors related to XML-files are stored in system.log. All other errors, which happened because Magento fails to find the right data to display a feature or load a page, are stored in exception.log. These files can be renamed for your convenience in the configuration settings.Log for all third-party extensions installed in your store is also kept in the var/log folder.
Dealing With Blank PagesIf a blank page happens, it probably has nothing to deal with Magento itself and the error took place in other applications, most likely by Apache/PHP. The blank page is usually a PHP fatal error. Therefore, you should check Apache logs for some clues. There is no permanent location for the ErrorLog file, but if it is there, you can always find it via command line by running phpinfo(). To make sure Apache creates logs, have log_errors enabled in the PHP settings, and error_reporting should be set to the corresponding error level.
Magento Error ReportsSometimes Magento works as it is supposed to even if an error took place. In this instance, this error is most likely to be logged anyway. The possible location for this is the report folder. You can find it under MAGENTO/var/report.Is there are issues, this folder will contain files named by numbers. Each file includes the error message and a PHP trace. To know what happened, you need only the first line of the error message, while the rest of it might be useful for developers to detect the problem and fix it.
ConclusionImportant points to remember:
- Check Magento reports once in a while to make sure everything is doing great. If manual monitoring seems exhausting and gets forgotten among other administrative duties, you can use an automated solution, like the Log Monitoring extension by NEKLO. It will handle log checking for you and ensure timely email notifications about new log errors.
- For Magento 1 and Magento 2 exceptions are stored differently in logs and report folders. If you need to view other Magento errors, they are in logs.
- Magento logs do not handle fatal errors, so don’t forget to pay attention to Apache logs.