About
We know sometimes things go wrong with a website this can be from a plugin that caused a critical error or a deployment that was unsuccessful. It is important to know where to look when troubleshooting your Magento website. Magento provides a couple of locations to assist in troubleshooting errors that the website is experiencing. Knowing were to find these can help your team respond to the issue promptly. This article contains a brief overview of these locations with examples.
In the following, we assume that Magento’s public directory is in
/home/jetrails/example.com/html
.
Magento logs
You will find several log files in the /home/jetrails/example.com/html/var/log
directory. Normally these logs are enabled by default. You will find your Magento exception.log
and system.log
files here. It is also possible to use this directory for extension debug logs. The logs will provide you with errors, warnings and information that is related to the application. Your team can make adjustments to Magento to allow more verbose output. However, that is outside the scope of this article. The logs found in this directory will provide you with a timestamp, log level and details of the exception. A couple of examples you may see in these logs are below. We truncated the output for brevity.
$ tail -n 2 /home/jetrails/example.com/html/var/log/exception.log
2022-06-18T18:08:50.534319+00:00 main.ERROR: Directory "/home/jetrails/example.com/html/pub/static/frontend" cannot be created Warning!mkdir(): Permission denied
2022-06-24T12:48:02.815020+00:00 main.CRITICAL: UnexpectedValueException: Unable to retrieve deployment version of static files from the file system. in /home/jetrails/example.com/html/vendor/magento/framework/App/View/Deployment/Version.php:88
Magento reports
Magento provides the directory found in /home/jetrails/example.com/html/var/report
to store immediate critical errors that are effecting the website. The errors in this directory can provide vital information to help troubleshoot your website. As a security measure the error is not shown by default. Magento provides an error log record number which consists of a long string of alpha-numeric characters. For example, you might see something like this:
You can print the error message by using the cat
command:
$ cd /home/jetrails/example.com/html/var/report/
$ cat 2a2b5413a444cee978acce74c93a82ea2fc7c505a31c7eb2064c21782203557e
"0":"Unable to retrieve deployment version of static files from the file system.","1":"#1 Magento\\Framework\\App\\View\\Deployment\\Version->getValue() called at [vendor\/magento\/module-theme\/Model\/Url\/Plugin\/Signature.php:87]\n#2 Magento\\Theme\\Model\\Url\\Plugin\\Signature->renderUrlSignature()...
Note: The above output only has details of the exception and was truncated for brevity.
NGINX/PHP-FPM logs
There are a couple more great sources of information to help you troubleshoot an issue. The first is the NGINX access log and the second is the PHP-FPM error log.
The NGINX access log is located in the following path /home/jetrails/example.com/logs/example.com-ssl-access_log
. The log here will show you the connecting IP address, status code, user agent and request method. Here are some examples of the output below:
$ tail /home/jetrails/example.com/logs/example.com-ssl-access_log
69.27.47.6 - - [30/Sep/2022:08:39:33 -0500] "GET /static/version1656103543/frontend/Magento/luma/en_US/Magento_Ui/template/messages.html HTTP/2.0" 200 348 "https://example.com/women/tops-women.html" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36"
69.27.47.6 - - [30/Sep/2022:08:39:33 -0500] "GET /static/version1656103543/frontend/Magento/luma/en_US/Magento_Captcha/template/checkout/captcha.html HTTP/2.0" 200 676 "https://example.com/women/tops-women.html" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36"
69.27.47.6 - - [30/Sep/2022:08:39:37 -0500] "GET /media/catalog/product/cache/4eb7c9e66c3ca59ce33306c971696798/w/s/ws05-black_main_1.jpg HTTP/2.0" 200 7855 "https://example.com/women/tops-women.html" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36"
69.27.47.6 - - [30/Sep/2022:08:39:37 -0500] "GET /media/catalog/product/cache/4eb7c9e66c3ca59ce33306c971696798/w/t/wt06-blue_main_1.jpg HTTP/2.0" 200 7047 "https://example.com/women/tops-women.html" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36"
69.27.47.6 - - [30/Sep/2022:08:39:37 -0500] "GET /media/catalog/product/cache/4eb7c9e66c3ca59ce33306c971696798/w/t/wt07-green_main_1.jpg HTTP/2.0" 200 6495 "https://example.com/women/tops-women.html" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36"
69.27.47.6 - - [30/Sep/2022:08:39:37 -0500] "GET /media/catalog/product/cache/4eb7c9e66c3ca59ce33306c971696798/w/s/ws01-black_main_1.jpg HTTP/2.0" 200 7969 "https://example.com/women/tops-women.html" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36"
69.27.47.6 - - [30/Sep/2022:08:39:37 -0500] "GET /media/catalog/product/cache/4eb7c9e66c3ca59ce33306c971696798/w/t/wt08-black_main_1.jpg HTTP/2.0" 200 6831 "https://example.com/women/tops-women.html" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36"
69.27.47.6 - - [30/Sep/2022:08:39:37 -0500] "GET /media/catalog/product/cache/4eb7c9e66c3ca59ce33306c971696798/w/h/wh11-blue_main_1.jpg HTTP/2.0" 200 8222 "https://example.com/women/tops-women.html" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36"
69.27.47.6 - - [30/Sep/2022:08:39:37 -0500] "GET /media/catalog/product/cache/4eb7c9e66c3ca59ce33306c971696798/w/t/wt05-purple_main_2.jpg HTTP/2.0" 200 8069 "https://example.com/women/tops-women.html" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36"
69.27.47.6 - - [30/Sep/2022:08:39:37 -0500] "GET /media/catalog/product/cache/4eb7c9e66c3ca59ce33306c971696798/w/h/wh12-gray_main_1.jpg HTTP/2.0" 200 7069 "https://example.com/women/tops-women.html" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36"
The next log file is the PHP-FPM error log located at /home/jetrails/example.com/logs/example.com-ssl-error_log
. Below is an example of the type of errors you may find in the error log. In the output below you will see warnings regarding deprecated use of the trim
function in PHP-FPM 8.1.
$ tail /home/jetrails/example.com/logs/example.com-ssl-error_log
2022/09/30 08:37:11 [error] 2488847#2488847: *20249 FastCGI sent in stderr: "PHP message: PHP Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/jetrails/example.com/html/vendor/magento/module-media-storage/App/Media.php on line 151" while reading response header from upstream, client: 127.0.0.1, server: example.com, request: "GET /media/catalog/product/cache/4eb7c9e66c3ca59ce33306c971696798/w/s/ws12-orange_main_2.jpg HTTP/1.1", upstream: "fastcgi://unix://run/php/php-fpm-jetrails-81.sock:", host: "example.com", referrer: "https://example.com/"
2022/09/30 08:37:11 [error] 2488847#2488847: *20227 FastCGI sent in stderr: "PHP message: PHP Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/jetrails/example.com/html/vendor/magento/module-media-storage/App/Media.php on line 151" while reading response header from upstream, client: 127.0.0.1, server: example.com, request: "GET /media/catalog/product/cache/4eb7c9e66c3ca59ce33306c971696798/m/t/mt07-gray_main_1.jpg HTTP/1.1", upstream: "fastcgi://unix://run/php/php-fpm-jetrails-81.sock:", host: "example.com", referrer: "https://example.com/"
2022/09/30 08:37:11 [error] 2488847#2488847: *20245 FastCGI sent in stderr: "PHP message: PHP Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/jetrails/example.com/html/vendor/magento/module-media-storage/App/Media.php on line 151" while reading response header from upstream, client: 127.0.0.1, server: example.com, request: "GET /media/catalog/product/cache/4eb7c9e66c3ca59ce33306c971696798/w/t/wt09-white_main_1.jpg HTTP/1.1", upstream: "fastcgi://unix://run/php/php-fpm-jetrails-81.sock:", host: "example.com", referrer: "https://example.com/"
Conclusion
This article was a brief overview of often overlooked log files. Providing our support team with the error messages found in these log files will aid in troubleshooting the issue. We can use this information to come to a possible resolution quicker. If you have any questions about the contents of these log files, feel free to open at ticket with our support team.