{"id":539,"date":"2021-11-19T12:56:14","date_gmt":"2021-11-19T12:56:14","guid":{"rendered":"http:\/\/blog.hostinger.io\/hostinger-tutorials\/%category\/websitehow-to-check-your-website-error-log\/"},"modified":"2024-07-02T08:44:17","modified_gmt":"2024-07-02T08:44:17","slug":"php-error-log","status":"publish","type":"post","link":"\/ph\/tutorials\/website\/how-to-check-your-website-error-log","title":{"rendered":"How to Check Your Website&#8217;s PHP Error Log"},"content":{"rendered":"<p>Any website can go through some troubles and stop working. When this happens, it will display an error message to you and the visitors. Unfortunately, messages such as HTTP 500 don&rsquo;t provide a lot of information on why the error occurred and what you should do to fix it.<\/p><p>This is where the PHP error log comes into play. It&rsquo;s a file that contains information about PHP errors that happen on a website.<\/p><p>Finding and checking the PHP error log can be tricky for a less tech-savvy user. Thus, this article will guide you on how to enable PHP error logging, check it, and understand the information logged.<\/p><figure class=\"wp-block-image size-large is-resized\"><a href=\"https:\/\/assets.hostinger.com\/content\/tutorials\/pdf\/Build-WordPress-Website-in-9%20Steps.pdf\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" width=\"1024\" height=\"283\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2022\/11\/eBook_-Build-website-in-9-steps_in-text-banner-1-1024x283.png\" alt=\"\" class=\"wp-image-69276\" style=\"width:840px;height:auto\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2022\/11\/eBook_-Build-website-in-9-steps_in-text-banner-1-1536x425.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2022\/11\/eBook_-Build-website-in-9-steps_in-text-banner-1-300x83.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2022\/11\/eBook_-Build-website-in-9-steps_in-text-banner-1-150x41.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2022\/11\/eBook_-Build-website-in-9-steps_in-text-banner-1-768x212.png 768w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2022\/11\/eBook_-Build-website-in-9-steps_in-text-banner-1.png 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><p>\n\n\n\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-enable-php-error-logging\">How to Enable PHP Error Logging<\/h2><p>It is only possible to check the PHP error log if it&rsquo;s enabled on your web hosting account. Unfortunately, the error logging on a website&rsquo;s directory is disabled by default in most cases.<\/p><p>However, before tweaking some code and the web hosting configuration, take a look at the PHP info to know whether PHP logging is enabled on your hosting account. Here are the steps to do so in hPanel:<\/p><ol class=\"wp-block-list\">\n<li>Log in to your hPanel account.<\/li>\n\n\n\n<li>Head to the <strong>Advanced <\/strong>section and click <strong>PHP Info<\/strong>.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/03\/hpanel-advanced-phpinfo-sidebar.png\"><img decoding=\"async\" width=\"452\" height=\"422\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/03\/hpanel-advanced-phpinfo-sidebar.png\" alt=\"The Advanced section on hPanel\" class=\"wp-image-80682\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/03\/hpanel-advanced-phpinfo-sidebar.png 452w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/03\/hpanel-advanced-phpinfo-sidebar-300x280.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/03\/hpanel-advanced-phpinfo-sidebar-150x140.png 150w\" sizes=\"(max-width: 452px) 100vw, 452px\" \/><\/a><\/figure><\/div><ol class=\"wp-block-list\" start=\"3\">\n<li>Press <strong>CTRL + F <\/strong>for Windows or <strong>Command + F <\/strong>for MacOS<strong> <\/strong>to open the search bar. Type <strong>log_errors<\/strong> to find the <strong>log_errors <\/strong>row. If the value is <strong>Off<\/strong>, then the PHP error logging is disabled.<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"\/ph\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/11\/log-errors.png\"><img decoding=\"async\" width=\"933\" height=\"134\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/11\/log-errors.png\" alt=\"Locating the log_errors row\" class=\"wp-image-39961\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/log-errors.png 933w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/log-errors-300x43.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/log-errors-150x22.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/log-errors-768x110.png 768w\" sizes=\"(max-width: 933px) 100vw, 933px\" \/><\/a><\/figure><\/div><p>Or, if you don&rsquo;t use hPanel, <a href=\"\/ph\/tutorials\/how-to-create-phpinfo-file\">create a <strong>phpinfo.php<\/strong><\/a><strong> <\/strong>file to access the PHP info. Use an FTP client or the hosting&rsquo;s file manager and perform the following steps:<\/p><ol class=\"wp-block-list\">\n<li>Open the <strong>public_html <\/strong>directory.<\/li>\n\n\n\n<li>Create a <strong>phpinfo.php <\/strong>file. If the file already exists, open it and make sure it contains the code from <strong>Step 3<\/strong>.<\/li>\n\n\n\n<li>Open the file and insert the following line:<br><code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">&lt;?php<\/code><br><code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">phpinfo();<\/code><br><code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">?&gt;<\/code><\/li>\n<\/ol><ol class=\"wp-block-list\" start=\"4\">\n<li>Save and close the file.<\/li>\n\n\n\n<li>Go to<strong> yourdomain.com\/phpinfo.php<\/strong>., replacing <strong>yourdomain <\/strong>with the actual domain name. It will show the PHP configuration details, like this:<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"\/ph\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/11\/php-details.png\"><img decoding=\"async\" width=\"932\" height=\"563\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/11\/php-details.png\" alt=\"PHP configuration details\" class=\"wp-image-39962\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/php-details.png 932w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/php-details-300x181.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/php-details-150x91.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/php-details-768x464.png 768w\" sizes=\"(max-width: 932px) 100vw, 932px\" \/><\/a><\/figure><\/div><ol class=\"wp-block-list\" start=\"6\">\n<li>Press <strong>CTRL + F <\/strong>for Windows or <strong>Command + F <\/strong>for MacOS<strong> <\/strong>to open the search bar on your web browser. Type <strong>log_errors<\/strong> to find the <strong>log_errors <\/strong>row. If the value is <strong>Off<\/strong>, then the PHP error logging is disabled.<\/li>\n<\/ol><p>There are three ways to turn on the PHP error log, depending on the hosting platform:<\/p><ul class=\"wp-block-list\">\n<li>Accessing the hPanel if you are Hostinger&rsquo;s <a href=\"\/ph\/wordpress-hosting\">WordPress<\/a>, <a href=\"\/ph\/cloud-hosting\">cloud<\/a> or <a href=\"\/ph\/web-hosting\">standard web hosting<\/a> plans.<\/li>\n\n\n\n<li>Editing the<strong> .htaccess<\/strong> file.<\/li>\n\n\n\n<li>Editing the <strong>php.ini<\/strong> file if you are a Linux desktop or Linux VPS hosting user.<\/li>\n<\/ul><h3 class=\"wp-block-heading\" id=\"h-how-to-enable-error-log-using-hpanel\">How to Enable Error Log Using hPanel<\/h3><p>Enabling PHP error logs on hPanel is easy as there&rsquo;s a dedicated setting for that. Follow these simple steps:<\/p><ol class=\"wp-block-list\">\n<li>Access the hPanel.<\/li>\n\n\n\n<li>Head to the <strong>Advanced <\/strong>section and click <strong>PHP Configuration<\/strong>:<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/03\/hpanel-advanced-phpconfiguration.png\"><img decoding=\"async\" width=\"398\" height=\"316\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2023\/03\/hpanel-advanced-phpconfiguration.png\" alt=\"Hostinger left side menu Advanced section with PHP configuration highlighted\" class=\"wp-image-80692\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/03\/hpanel-advanced-phpconfiguration.png 398w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/03\/hpanel-advanced-phpconfiguration-300x238.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2023\/03\/hpanel-advanced-phpconfiguration-150x119.png 150w\" sizes=\"(max-width: 398px) 100vw, 398px\" \/><\/a><\/figure><\/div><ol class=\"wp-block-list\" start=\"3\">\n<li>Open the <strong>PHP options <\/strong>and tick the <strong>logErrors <\/strong>box:<\/li>\n<\/ol><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"\/ph\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/11\/logerrors.png\"><img decoding=\"async\" width=\"745\" height=\"263\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/11\/logerrors.png\" alt=\"PHP options, highlighting the logErrors box\" class=\"wp-image-39964\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/logerrors.png 745w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/logerrors-300x106.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/logerrors-150x53.png 150w\" sizes=\"(max-width: 745px) 100vw, 745px\" \/><\/a><\/figure><\/div><ol class=\"wp-block-list\" start=\"4\">\n<li>Scroll down to the bottom of the section and click <strong>Save<\/strong>.<\/li>\n<\/ol><p>The system now will generate the <strong>error_log <\/strong>file when the site encounters an error, such as <a href=\"\/ph\/tutorials\/502-bad-gateway\">502 bad gateway<\/a>. Follow these steps to open the file:<\/p><p>1. Open the <strong><a href=\"\/ph\/tutorials\/how-to-use-hostinger-file-manager\/\">File Manager<\/a><\/strong> and the <strong>Access all files of Hosting<\/strong> option:<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/11\/hpanel-files-filemanager-accessallfiles-highlighted.png\"><img decoding=\"async\" width=\"1024\" height=\"173\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/11\/hpanel-files-filemanager-accessallfiles-highlighted-1024x173.png\" alt=\"The Access all files of hosting option for the Hostinger file manager\" class=\"wp-image-86517\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/hpanel-files-filemanager-accessallfiles-highlighted.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/hpanel-files-filemanager-accessallfiles-highlighted-300x51.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/hpanel-files-filemanager-accessallfiles-highlighted-150x25.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/hpanel-files-filemanager-accessallfiles-highlighted-768x130.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p>2. Go to the <strong>.logs<\/strong> directory.<\/p><figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/11\/filemanager-logs-highlighted.png\"><img decoding=\"async\" width=\"1024\" height=\"506\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/11\/filemanager-logs-highlighted-1024x506.png\" alt=\"The .logs folder on Hostinger file manager\" class=\"wp-image-86514\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/filemanager-logs-highlighted.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/filemanager-logs-highlighted-300x148.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/filemanager-logs-highlighted-150x74.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/filemanager-logs-highlighted-768x380.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><p>3. Find the <strong>error_log_[domain] <\/strong>file.<\/p><p>When you open the file, it will show the error log messages, including the date when the error occurred, the type of error, and even the details of the file and line that need correction.<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/11\/filemanager-errorlog.png\"><img decoding=\"async\" width=\"1024\" height=\"203\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/11\/filemanager-errorlog-1024x203.png\" alt=\"The error_log file on hPanel's File Manager\" class=\"wp-image-86513\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/filemanager-errorlog.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/filemanager-errorlog-300x60.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/filemanager-errorlog-150x30.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/filemanager-errorlog-768x152.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div><p>In the example above, the error log specifies an unexpected <strong>IF <\/strong>syntax on line 109 of the <strong>functions.php<\/strong> file. Such information helps to locate the error quickly and take corrective action.<\/p><h3 class=\"wp-block-heading\">How to Use hPanel to Display Errors<\/h3><p>Additionally, hPanel lets you easily enable the <strong>displayErrors<\/strong> option. For that, refer to the following steps:<\/p><p>1. Access the hPanel.<\/p><p>2. Head to the <strong>Advanced <\/strong>&rarr; <strong>PHP Configuration<\/strong> section:<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2017\/01\/hpanel-advanced-phpconfiguration.png\"><img decoding=\"async\" width=\"398\" height=\"316\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2017\/01\/hpanel-advanced-phpconfiguration.png\" alt=\"Hostinger left side menu Advanced section with PHP configuration highlighted\" class=\"wp-image-79456\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2017\/01\/hpanel-advanced-phpconfiguration.png 398w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2017\/01\/hpanel-advanced-phpconfiguration-300x238.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2017\/01\/hpanel-advanced-phpconfiguration-150x119.png 150w\" sizes=\"(max-width: 398px) 100vw, 398px\" \/><\/a><\/figure><\/div><p>3. Open the <strong>PHP options <\/strong>and tick the <strong>displayErrors <\/strong>box:<\/p><figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/11\/hpanel-advanced-phpconfiguration-phpoptions-displayerrors-highlighted.png\"><img decoding=\"async\" width=\"1024\" height=\"368\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/11\/hpanel-advanced-phpconfiguration-phpoptions-displayerrors-highlighted-1024x368.png\" alt=\"The PHP Configuration page on hPanel. The option with enabled displayErrors is highlighted\" class=\"wp-image-86511\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/hpanel-advanced-phpconfiguration-phpoptions-displayerrors-highlighted.png 1024w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/hpanel-advanced-phpconfiguration-phpoptions-displayerrors-highlighted-300x108.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/hpanel-advanced-phpconfiguration-phpoptions-displayerrors-highlighted-150x54.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/hpanel-advanced-phpconfiguration-phpoptions-displayerrors-highlighted-768x276.png 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><p>4. <strong>Save <\/strong>the changes<\/p><p>5. Lastly, visit your website, and the PHP error will be displayed:<\/p><figure class=\"wp-block-image size-full\"><a href=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/11\/wordpresswebsite-parserror.png\"><img decoding=\"async\" width=\"964\" height=\"364\" src=\"https:\/\/www.hostinger.com\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/11\/wordpresswebsite-parserror.png\" alt=\"The parse error on a WordPress website after enabling the displayErrors option on hPanel\" class=\"wp-image-86515\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/wordpresswebsite-parserror.png 964w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/wordpresswebsite-parserror-300x113.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/wordpresswebsite-parserror-150x57.png 150w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/wordpresswebsite-parserror-768x290.png 768w\" sizes=\"(max-width: 964px) 100vw, 964px\" \/><\/a><\/figure><h3 class=\"wp-block-heading\" id=\"h-how-to-enable-error-log-using-the-htaccess-file\">How to Enable Error Log Using the .htaccess File<\/h3><p>If you don&rsquo;t use Hostinger and can&rsquo;t find any PHP error log settings on the provider&rsquo;s control panel, enable it by editing the <strong>.htaccess <\/strong>file.<\/p><p><a href=\"\/ph\/tutorials\/locate-and-create-htaccess\">Locate the <strong>.htaccess <\/strong>file<\/a> using the file manager or an <a href=\"\/ph\/tutorials\/ftp\/filezilla-ftp-configuration\">FTP client<\/a>. It should be located inside the site&rsquo;s root<strong> <\/strong>directory. However, the file is hidden in some cases. In that case, go to the settings on the control panel or FTP client to display hidden files.<\/p><p>\n\n\n<div><p class=\"important\"><strong>Important!<\/strong> Back up the <b>.htaccess<\/b> file before making any changes.<\/p><\/div>\n\n\n\n<\/p><p>Once you&rsquo;ve found the <strong>.htaccess <\/strong>file, follow the following steps:<\/p><ol class=\"wp-block-list\">\n<li>Open the<strong> .htaccess <\/strong>file and insert the following code:<br><code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">php_flag log_errors on<\/code><br><code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">php_value error_reporting 32767<\/code><br><code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">php_value error_log \"error_log.txt\"<\/code><\/li>\n<\/ol><ol class=\"wp-block-list\" start=\"2\">\n<li>Create a file titled <strong>error_log.txt <\/strong>in the <strong>public_html <\/strong>directory<\/li>\n\n\n\n<li>Save and close it. All PHP error logs will be reported in the <strong>error_log.txt <\/strong>file.<\/li>\n<\/ol><p>Now the PHP error logging is enabled. You can check it by using the PHP info again, and the <strong>Local Value <\/strong>should be on. Don&rsquo;t worry if the <strong>Master Value <\/strong>is still off, as the local value will override it.<\/p><p>If the site encounters any trouble, open the <strong>error_log.txt<\/strong>,<strong> <\/strong>and you&rsquo;ll see the PHP error logs.<\/p><h3 class=\"wp-block-heading\" id=\"h-how-to-enable-error-log-using-php-ini-file\">How to Enable Error Log Using php.ini File<\/h3><p>The third method to enable the PHP error log is by editing the <strong>php.ini<\/strong> file. It contains the default web server configuration for running PHP applications.<\/p><p>Note that the <strong>php.ini <\/strong>file is not accessible for standard hosting users as it requires server root access. Instead, this method is an alternative for Linux or VPS hosting users.<\/p><p><strong>Locating the php.ini File<\/strong><\/p><p>The directory may differ depending on whether it&rsquo;s on the <a href=\"\/ph\/tutorials\/what-is-cli\">command line interface (CLI)<\/a> or the web server&rsquo;s operating system, such as <a href=\"\/ph\/tutorials\/what-is-apache\">Apache<\/a> and <a href=\"\/ph\/tutorials\/what-is-nginx\">NGINX<\/a>.<\/p><p>Locate the <strong>php.ini <\/strong>file by accessing the PHP info. Once you open it, press <strong>CTRL + F <\/strong>for Windows or <strong>Command + F <\/strong>for MacOS to open the search bar and look for the <strong>Loaded Configuration File <\/strong>section. You&rsquo;ll find the directory of the <strong>php.ini <\/strong>file.<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"\/ph\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/11\/loaded-configuration.png\"><img decoding=\"async\" width=\"503\" height=\"92\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/11\/loaded-configuration.png\" alt=\"Loaded Configuration File section\" class=\"wp-image-39967\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/loaded-configuration.png 503w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/loaded-configuration-300x55.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/loaded-configuration-150x27.png 150w\" sizes=\"(max-width: 503px) 100vw, 503px\" \/><\/a><\/figure><\/div><p>Another method to find the configuration file is using the command line. <a href=\"\/ph\/tutorials\/how-to-use-putty-ssh\">Connect to the web server by using an SSH client<\/a> and execute the following command:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">php -i | grep php.ini<\/pre><p>It should print an output like this:<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><a href=\"\/ph\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/11\/configuration-file-output.png\"><img decoding=\"async\" width=\"419\" height=\"33\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/11\/configuration-file-output.png\" alt=\"Output of the load configuration file command\" class=\"wp-image-39968\" style=\"width:419px;height:33px\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/configuration-file-output.png 419w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/configuration-file-output-300x24.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/configuration-file-output-150x12.png 150w\" sizes=\"(max-width: 419px) 100vw, 419px\" \/><\/a><\/figure><\/div><p>That said, here are the common directories for <strong>php.ini <\/strong>file depending on the operating system:<\/p><ul class=\"wp-block-list\">\n<li><strong>CLI<\/strong> &ndash; <code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">\/etc\/php\/7.4\/cli\/php.ini<\/code>. Note that changing the PHP configuration in CLI won&rsquo;t affect the web server.<\/li>\n\n\n\n<li><strong>Apache <\/strong>&ndash; <code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">\/etc\/php\/7.4\/apache2\/php.ini<\/code>.<\/li>\n\n\n\n<li><strong>NGINX or Apache with PHP-FPM<\/strong> &ndash; <code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">\/etc\/php\/7.4\/fpm\/php.ini<\/code>.<\/li>\n<\/ul><p>\n\n\n<div><p class=\"important\"><strong>Important!<\/strong> If necessary, replace <strong>7.4<\/strong> with the PHP version you actually use.<\/p><\/div>\n\n\n\n<\/p><p><strong>Editing the php.ini File<\/strong><\/p><p>Once you locate the <strong>php.ini <\/strong>file, open and edit it<strong> <\/strong>with the <a href=\"\/ph\/tutorials\/how-to-install-and-use-nano-text-editor\">Nano text editor<\/a> using the following command:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">nano etc\/php\/7.4\/apache2\/php.ini<\/pre><p>Note that you should adapt the command depending on the <strong>php.ini <\/strong>path. It should print an output like this:<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"\/ph\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/11\/edit-php-ini-file.png\"><img decoding=\"async\" width=\"648\" height=\"359\" src=\"\/tutorials\/wp-content\/uploads\/sites\/2\/2021\/11\/edit-php-ini-file.png\" alt=\"Editing the php.ini file.\" class=\"wp-image-39969\" srcset=\"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/edit-php-ini-file.png 648w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/edit-php-ini-file-300x166.png 300w, https:\/\/www.hostinger.com\/ph\/tutorials\/wp-content\/uploads\/sites\/44\/2021\/11\/edit-php-ini-file-150x83.png 150w\" sizes=\"(max-width: 648px) 100vw, 648px\" \/><\/a><\/figure><\/div><p>Once you open the <strong>php.ini <\/strong>file, it will display the <a href=\"https:\/\/www.php.net\/manual\/en\/ini.list.php\" target=\"_blank\" rel=\"noopener\">configuration directives<\/a>. Change the values of these directives to configure the PHP setup on your web server.<\/p><p>When it comes to PHP error logging, there are three primary directives:<\/p><ul class=\"wp-block-list\">\n<li><strong>log_errors<\/strong> &ndash; toggles the PHP error logging. The default value is <strong>0,<\/strong> which indicates that PHP error logging is disabled.<\/li>\n\n\n\n<li><strong>error_log<\/strong> &ndash; sends the error message to the error log file. The default value is <strong>0<\/strong>, and you should set the absolute path for the error log file.<\/li>\n\n\n\n<li><strong>error_reporting<\/strong> &ndash; defines the minimum error reporting level. The value is <strong>null <\/strong>by default, and you should change its parameters to report all types of errors.<\/li>\n<\/ul><p>To configure those directives, simply use the following commands on the text editor:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">log_errors = on\nerror_reporting = E_All\nerror_log = \/path\/filename<\/pre><p>Be sure to replace<strong> \/path\/filename<\/strong> with the desired path and file name of the error log file. Alternatively, use this command to log errors in the system log:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">error_log = syslog<\/pre><p>Apart from these three main directives, several others are related to PHP error logging, such as:<\/p><ul class=\"wp-block-list\">\n<li><strong>display_errors<\/strong> &ndash; defines whether to display errors on the error output. We recommend disabling this as a security measure.<\/li>\n\n\n\n<li><strong>log_error_max_length<\/strong> &ndash; defines the maximum length of logged errors. Set the value to zero to disable the limit.<\/li>\n\n\n\n<li><strong>track_errors<\/strong> &ndash; specifies whether to store the last error message in the <code data-enlighter-language=\"generic\" class=\"EnlighterJSRAW\">$php_errormsg<\/code> variable.<\/li>\n<\/ul><h2 class=\"wp-block-heading\" id=\"h-most-common-php-error-log-types\">Most Common PHP Error Log Types<\/h2><p>One of the details that the PHP error log provides is the type of error that occurred. In general, there are four types of PHP errors. Understanding them is essential to know how to fix and prevent the same errors from happening again.<\/p><p><strong>Warning Error<\/strong><\/p><p>This error warns about a problem that may cause a more significant issue in the long run. However, it doesn&rsquo;t stop the script execution.<\/p><p>The most common cause is using a file path that doesn&rsquo;t exist. If you encounter this error, check the file name on the script or directory as a typo can make the script unable to find it.<\/p><p><strong>Notice Error<\/strong><\/p><p>A notice error is similar to a warning error, as it still allows the execution of the script. However, it usually indicates an undeclared or undefined variable in the script instead of a missing file.<\/p><p>Simply check the variable indicated in the error message.<\/p><p><strong>Parse Error<\/strong><\/p><p>A parse or syntax error indicates a wrong symbol, unclosed quote, missing semicolon, or misspelling in the script syntax. It terminates the script and can trigger error messages on WordPress sites.<\/p><p>The error logs will indicate the specific symbol or syntax that caused it, along with the file and code line, making it easy to <a href=\"\/ph\/tutorials\/how-to-fix-wordpress-syntax-error\">fix the syntax error<\/a>.<\/p><p>Here&rsquo;s an example of a parse error message:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">PHP Parse error: syntax error, unexpected &lsquo;2&rsquo; (T_LNUMBER), expecting &lsquo;)&rsquo; in \/home\/u802426761\/domains\/username\/public_html\/wp-config.php on line 54<\/pre><p>This error log indicates that there is a <strong>&ldquo;2&rdquo;<\/strong> character that&rsquo;s not supposed to be in <strong>line 54<\/strong> of the <strong><a href=\"\/ph\/tutorials\/wp-config-php\">wp-config.php<\/a><\/strong> file. To fix it, open the file and delete the problematic character.<\/p><p>\n\n\n<div class=\"protip\">\n                    <h4 class=\"title\">Pro Tip<\/h4>\n                    <p>When you open a file using hPanel&rsquo;s File Manager, the text editor will mark the problematic line with an X. It helps find the error quickly and alerts you for parse errors when tweaking files.<\/p>\n                <\/div>\n\n\n\n<\/p><p><strong>Fatal Error<\/strong><\/p><p>A fatal error happens when the script calls a function, but the function itself is not defined. Unlike the other types of PHP errors, a fatal error can crash the application. There are three types of fatal errors based on the time of occurrence:<\/p><ul class=\"wp-block-list\">\n<li><strong>Startup fatal error<\/strong> &ndash; occurs when the system can&rsquo;t run the code due to an error during the installation.<\/li>\n\n\n\n<li><strong>Compile-time fatal error<\/strong> &ndash; occurs when the programmer tries to use an undefined class, function, or non-existent data.<\/li>\n\n\n\n<li><strong>Runtime fatal error <\/strong>&ndash; similar to a compile-time fatal error, but it happens during the program execution.<\/li>\n<\/ul><p>Find the undefined function given in the error log and make sure to define and call the correct function. Also, check for any misspelling if you&rsquo;re using an inbuilt function.<\/p><p>Here&rsquo;s an example of a PHP fatal error:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">PHP Fatal error: Call to undefined function get_header() in \/var\/www\/username\/public\/blog\/wp-content\/themes\/theme\/index.php on line 37<\/pre><p>In this case, open the <strong>index.php <\/strong>file mentioned in the error log and check the function on <strong>line 37<\/strong> to ensure it is defined correctly.<\/p><p>Another common reason for a fatal error is exceeding the maximum execution time, which simply means that the PHP script takes longer to complete than the predetermined time limit. If this happens, the error log should look like this:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Fatal error: Maximum execution time of 30 seconds exceeded in \/home\/username\/domains\/domain.com\/public_html\/wp-includes\/class-phpmailer.php on line 737<\/pre><p>To fix it, you need to <a href=\"\/ph\/tutorials\/how-to-fix-maximum-execution-time-exceeded-error-wordpress\">configure the PHP maximum execution time<\/a>. It is possible to do it by editing the <strong>.htaccess <\/strong>file, configuring hPanel settings, or installing a WordPress plugin.<\/p><h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2><p>PHP error log helps you troubleshoot problems on a website by logging the error details, including the PHP file and code line that needs to be fixed. Having PHP error logging is a must, but, unfortunately, it&rsquo;s not enabled by default.<\/p><p>Let&rsquo;s recap the three methods to enable PHP error logging:<\/p><ul class=\"wp-block-list\">\n<li><strong>Using hPanel<\/strong> &ndash; only applicable if you&rsquo;re using Hostinger&rsquo;s standard, WordPress, or cloud hosting service. It lets you easily enable PHP error logging or PHP error display in a few clicks.<\/li>\n\n\n\n<li><strong>Editing the .htaccess file<\/strong> &ndash; applicable to almost all hosting users. Simply insert a few code lines into the .htaccess file.<\/li>\n\n\n\n<li><strong>Editing the php.ini file <\/strong>&ndash; applicable to VPS and Linux hosting users who have root access. This method involves tweaking the PHP configuration in the server and defining the PHP error log file path.<\/li>\n<\/ul><p>Once you&rsquo;ve got the PHP error logging enabled, check the error log file in the website directory unless you have specified the path differently.<\/p><p>However, it&rsquo;s always best to prevent errors from happening. Thus, always make sure to type the correct PHP syntax when tweaking the website&rsquo;s files. Also, pay attention to the indicator on the text editor when there&rsquo;s a syntax mistake.<\/p><p>\n\n\n<div class=\"protip\">\n                    <h4 class=\"title\">Suggested Reading<\/h4>\n                    <p> <a href=\"\/ph\/tutorials\/how-to-monitor-uptime-and-downtime\">Website Uptime and Downtime: What It Is, How to Monitor It and Improve Performance<\/a><br>\n <a href=\"\/ph\/tutorials\/website-maintenance-cost\">Website Maintenance Cost<\/a><br>\n <a href=\"\/ph\/tutorials\/hacked-website\">How to Diagnose and Fix a Hacked Website<\/a><br>\n <a href=\"\/ph\/tutorials\/backups\/downloading-website-backup\">How to Download a Website Backup (hPanel + cPanel)<\/a><br>\n <a href=\"\/ph\/tutorials\/clear-browser-cache\">How to Clear Browser Cache and History (Chrome, Firefox, Safari)<\/a><\/p>\n                <\/div>\n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Any website can go through some troubles and stop working. When this happens, it will display an error message to you and the visitors. Unfortunately, messages such as HTTP 500 don&rsquo;t provide a lot of information on why the error occurred and what you should do to fix it. This is where the PHP error [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/ph\/tutorials\/website\/how-to-check-your-website-error-log\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":24,"featured_media":69236,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"How to Check Your Website's PHP Error Log: A Step-by-Step Guide","rank_math_description":"Do you get unknown PHP errors on your website? Check out our step-by-step tutorial on how to locate and check your PHP error log file.","rank_math_focus_keyword":"php log error","footnotes":""},"categories":[],"tags":[],"class_list":["post-539","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry"],"hreflangs":[],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/posts\/539","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/users\/24"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/comments?post=539"}],"version-history":[{"count":38,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/posts\/539\/revisions"}],"predecessor-version":[{"id":112492,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/posts\/539\/revisions\/112492"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/media\/69236"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/media?parent=539"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/categories?post=539"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/ph\/tutorials\/wp-json\/wp\/v2\/tags?post=539"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}