When you want to know if your store is working as expected, the error log is the place to go, or in some cases, when an error occurs, your customer may not be able to get the experience you want. The error message here can help your web site developer track down errors or fix problems that you have not actually encountered. Let’s take a look at how to use it and help you and your developers maintain system health.
In OpenCart, you can configure how the system handles errors. This can be done by going to System> Settings> Edit> Server and configuring the “Show errors” and “Log errors” options. We recommend that the Log Error option is always enabled. If you are developing a website, it is recommended that you also enable the “Show errors” option, otherwise disable this option.
Physical file and its size
Physically, the path to the error log file in the file system is system / logs / error.log, which usually ranges in size from a few kilobytes to 1-2 megabytes. OpenCart’s web viewer simply prints the contents of this file for you. However, in some cases, this file becomes very large (in megabytes), and then most likely you are having problems opening the Web Viewer. If this happens, you should manually back up the error log (by renaming it), so OpenCart can start recording a new file. If the file size grows rapidly in a short time, this is an indication that there is a frequent error that should be repaired urgently.
In OpenCart, each error logged through the log library (system / library / log.php) follows the same simple pattern, “date-error_message”, where date is the time saved to the second date, error_message is actual error. Most of the errors are descriptive, letting you know which parts of the system are causing the problem and contacting the appropriate developer (if it is from an extension) or providing more initial information to your site developer. For example, in the admin panel’s menu it is clear that an error occurred: “PHP NOTE: Undefined variable: In System / Modify / Administrator / View / Templates / Public / Menu.
Protect your error log
Unfortunately, the error logs in OpenCart are public by default, and you must perform additional work to protect them. This is important because errors usually expose the full file system path to the PHP file, which provides information about the operating system and user name. Fortunately, if your server is Apache, it is fairly easy to lock the error log by adding a .htaccess file to the system / logs / directory. The contents of the file should be “all denied” (without the quotes). To test whether you are vulnerable, try opening your Web site and appending the following to the URL “/system/logs/error.log” (again without the quotation marks). If you see your error log, then you are vulnerable. Now add the .htaccess file and try again. You should now see “forbidden”.
Give yourself super powers
Reading the raw logs may make it difficult to distinguish between different error messages or other useful information, such as the number of occurrences of an error. Do not worry, we have you covered. We created a module called Error Log Manager, which organizes errors and provides a good list with only unique error messages. The module can handle any file size (we have tested files up to 250MB) and have some neat features such as fast code preview and filter date. It also counts the number of occurrences of each error. You can look at pictures.