Score:0

Enable error logging from settings.php

pk flag

I am facing a The website encountered an unexpected error. error while setting up the site.

Most of the documentation I found online suggest to enable logging in the setting.php file.

I added this line in site/default/settings.php.

$config['system.logging']['error_level'] = 'verbose';

I added the following code.

error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

I added the following lines to the same settings.php file, at the bottom.

if (file_exists(__DIR__ . '/settings.local.php')) {
  include __DIR__ . '/settings.local.php';
}

I copied the sites/example.sites.php file to sites/default/ and renamed it settings.local.php, as suggested on https://catwolf.org/qs?id=180d30e9-9dcb-4e96-b030-7df34c77f5ab&x=x and https://www.drupal.org/forum/support/post-installation/2018-07-18/enable-drupal-8-backend-errorlogdebugging-mode.

I restarted Apache and reloaded the site, but I see the same error shows again without any log.

I am migrating a Drupal 7.84 site from CentOS 6.10 to CentOS 7.9. The httpd passes from version 2.2.15 to version 2.4.6; it also has PHP 7.03 and MariaDB 10.3.

Did I miss anything, or do I have to do anything else to enable the logging?

us flag
If you added those settings just below `<?php`, make sure that they are not overwritten later in the file. Also, `example.sites.php` is not a template for `settings.local.php`. BTW - What is your version of Drupal? In 7 the setting name was different.
jayaprakash R avatar
pk flag
My drupal version is 7.84. I don't know where I have to add this line. Once I resolve this I will remove those lines as it is the production server. I am in the migration process. I am migrating the drupal 7.84 site from centos 6.10 to centos 7.9. Httpd version also changes from 2.2.15 to 2.4.6. Php v7.03 and mariadb v10.3. I hope this info may help
cn flag
If you are temporarily adding lines to a file to try to change things, always add them to the bottom of the file first. This will ensure that the lines override any logic in the file because they will be the last to be executed.
jayaprakash R avatar
pk flag
Added as you said @patrick but no luck. shows asusual same error
Score:1
fr flag

Please try the following:

  • in the webroot, rename .htaccess to .htaccess.old -- Apache 2.4 has changed syntax in some directives that may be causing the error before PHP is even reached. Also check apache log files ( usually /var/log/httpd/error.log, see your VirtualHost for other paths )
  • check your PHP file logs, since some errors never make it to the screen even with all the above listed directives -- on CentOS these are normally under /var/log/php*

One of the above should have a log entry on what went wrong.

jayaprakash R avatar
pk flag
Thanks for you suggestion @nick i checked all the logs you mentioned For apache log, `[core:notice] [pid 22268] SELinux policy enabled; httpd running as context system_u:system_r:httpd_t:s0 [Tue May 03 07:22:21.732165 2022] [suexec:notice] [pid 22268] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)`........ For php log `fpm is running, pid 1497 NOTICE: ready to handle connections NOTICE: systemd monitor interval set to 10000ms NOTICE: Terminating NOTICE: exiting, bye-bye!`......... I disabled the firewall and SELinux but shows the same error
jayaprakash R avatar
pk flag
I renamed the .htaccess file as you mentioned and reloaded the apache and site but same error appears
Score:1
us flag

Here's the official manual for Drupal 7: https://www.drupal.org/docs/7/creating-custom-modules/show-all-errors-while-developing

At the end of your sites/default/settings.php, add the following lines:

error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
$conf['error_level'] = 2;

Please pay extra attention to the last line, as it is specific to D7. Your code was for D8/D9.

Of course those changes can be also made to settings.local.php, but I would try to do it after making sure that $conf['error_level'] = 2; works at all at the end of settings.php.

jayaprakash R avatar
pk flag
Thanks for your suggestion @grzegorz. I tried to add it at the end of the setting.php file but no luck. Do you know why it didn't execute?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.