Drupal включить отображение ошибок

Set Drupal to show all errors when developing your module.

Some errors are only reported when all PHP error reporting is switched on. Without the error reporting on, you get the dreaded White Screen of Death.

Check for errors behind the scenes

As an alternative between showing no errors and showing all errors, you may wish to monitor the errors being generated by your site by running

tail -f /var/log/apache2/error.log

on your server.

Change settings in your dev site

You can show all errors by adding a few lines to your local testing site’s settings.php:

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

In addition, navigate to Administration→ Configuration→ Development → logging and errors and select «All messages». (This sets $conf['error_level'] = 2;.)

Switch on strict PHP error reporting

Or you can go through your development site’s php.ini file, in the php folder, and switch all error reporting on. To do this, check through your php.ini file and set error_reporting to E_ALL. The documentation there is very thorough, and you may find a different setting that’s better suited to your needs. Warning: as the PHP documentation states, this setting is only for development sites, not for production sites.

Drupal надстраивает собственные разрешения на вывод ошибок, потому если вам необходим вывод ошибок на этапе разработки, то важно знать как разрешить их показ/протоколирование.

Чтобы не разбираться в конфигурации конкретно вашего веб-сервера, воспользуемся командами ini_set и error_reporting для настройки вывода PHP ошибок уже во время исполнения скрипта.

Инструкции нужно добавить в файл конфигурации вашего Drupal сайта (по умолчанию это — /sites/default/settings.php).

error_reporting(E_ALL);

ini_set(‘display_errors’, TRUE);

ini_set(‘display_startup_errors’, TRUE);

Это не гарантирует вывод ошибок, т.к. Drupal может иметь собственные настройки. Их можно изменить в админ панели — вот тут /admin/config/development/logging или жестко зафиксировав в конфигурации:

$conf[‘error_level’] = 2;

Это будет соответствовать выбору ‘All messages’ в админке.

Drupal 7

Написать комментарий


Данная запись опубликована в 24.01.2020 13:45 и размещена в drupal.
Вы можете перейти в конец страницы и оставить ваш комментарий.

Мало букафф? Читайте есчо !

  1. Главная
  2. Форумы
  3. Техподдержка Drupal
  4. Решение проблем

Ошибки и предупреждения видны только Админу (Drupal 7)?

Главные вкладки

  • Просмотр(активная вкладка)
  • Реакции

Аватар пользователя HESHES
HESHES


5 января 2014 в 5:12


На странице admin/config/development/logging есть опция «Отключить отображение всех ошибок на сайте» (рекомендуется не выводить ошибки на монитор на рабочем сайте).

Но как-то можно включить отображение ошибок только для Админа?

Если роль админ, то показывать ошибки. А по-умолчанию — не показывать — ?

  • Drupal7
  • Есть вопрос
  • Решение проблем
  • Блог
  • Войдите или зарегистрируйтесь, чтобы отправлять комментарии

Комментарии

Аватар пользователя drupby
drupby


5 января 2014 в 5:41




«OH Labs» wrote:

Но как-то можно включить отображение ошибок только для Админа?

ну так гугл по запросу «drupal error messages only for admin» дает кучу результатов с решением

Аватар пользователя Murdok
Murdok


5 января 2014 в 9:08




Они вроде только для админа и должны отображаться. Но на всякий проверьте сайт под анонимом, и под обычным пользователем. Мало ли что там у вас.

Аватар пользователя VasyOK
VasyOK


5 января 2014 в 13:02




Аватар пользователя drupby
drupby


5 января 2014 в 13:24




Аватар пользователя HESHES
HESHES


7 января 2014 в 4:44




Ничего не прокатывает.

Если скрывать через админку, то ДЛЯ ВСЕХ скрываются варинги/нотисы.

Disable_messages — отключает зеленые, желтые или красные сообщения. В красные входят нотисы и варинги (их и надо скрыть от всех, кроме админа) + служебные.
НО если убрать красные у юзеров, то скрываются и служебные вспомогательные сообщения, типо «Вы не заполнили поле.. и т.п.»

Ну и темизация также работает.. по цвету, вроде как.

Нужно отделить как-то ИЗ КРАСНЫХ МЕССАГ — только PHP-варинги/нотисы, и их то не показывать, не отключая при этом, другие полезные «Красные» сообщения..

Аватар пользователя univerico
univerico


25 января 2018 в 19:30




Тоже это пытаюсь решить
Нужно все же уточнить, какие есть полезные сообщения? У моделя немного своя теримнология.
В настройках модуля на странице /admin/config/development/disable-messages написано
что можно настроить еще и правах на странице /admin/people/permissions
Там три типа
— View status messages
-View warning messages
-View error messages
и четвертый вариант Exclude from message filtering
При включении показывать warnings, то что идет как обычные Warnings не проходит, а проходит при включении View error messages. Полезные красные сообщения, которые Вы имеете ввиду это status messages, warning messages или error messages?
При проведении теста именно на предмет сообщений о незаполнении полей у меня получилось:
-при выключении всех 4 вариантов, если не заполнить поле, то оно просто выделяется красным, и сообщения ни для пользователя текстове об этом, ни другие сообщения для админа не выводятся.
-при включении только View warning messages такакая же ситуация, но видимо еще и будут выводиться какие-то другие сообщения Warnings (которых у меня просто не было в данный момент на сайте).

Если у вас вдруг, чтобы вы не делали в Drupal не отображаются ошибки (errors) или предупреждения (warnings) PHP, то возможно вам следует заглянуть на следующую страничку конфигурирования системы — http://example-drupal-site.com/admin/config/development/logging. Возможно там просто нужно будет правильно выставить переключатель, — смотрите скриншот, который показан ниже:

Drupal 7 - logging and errors

Описанные опции можно найти по пути Главная » Администрирование » Конфигурация » Разработка » Logging and errors.

Материал актуален применительно к Drupal 7.

Опубликовано 7-01-2014 в 11:52

If you got a generic error in Drupal and are not sure why then it’s time to enable Drupal Debug Mode options and error reporting.

This is not helpful :(

The website encountered an unexpected error. Please try again later.

This is really important for the backend as well as the frontend developers to see the full error on your screen while you are working because you might not know what is the exact issue with your Drupal site with just a generic error statement.

Drupal Backend Debug Options

Let’s go through some Drupal Debug options for the backend.

1. Enable backtrace errors

In Drupal, there is a way to backtrace the error and display it in the message area. You can put the following code in your settings.local.php or settings.php whichever you are using.

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

This makes the development easier on local as it will show the backtrace of the error which you can debug now.

2. Enable Error message to display

For local Drupal development, you should always enable «Error message to display» options in the «/admin/config/development/logging» configuration. This will give you more information about the errors.

Twig Debug Options for Frontend

Now let’s see how we can make frontend developer life easy by enabling Drupal Twig debugging options.

1. Enable Twig Debug Config

If you are a front-end developer and work around twig files to beautify the Drupal site then enabling the twig to debug configuration is a must.

You can enable this by copying the «sites/default/services.yml» file and renaming the new file to development.services.yml. Once you have the development.services.yml file you can just add a new twig debug parameter to it to enable the twig debugging and see the error information.

parameters:
    twig.config:
        debug: true

By enabling the twig config you will be able to find from which TWIG template file the HTML markup is coming.

Now you will also be able to see what the other twig template suggestions which will override the current template.

It will also let you know the theme in which the twig template file is located so that you don’t start editing the wrong twig file.

2. Debug variables in Twig

Once you have enabled twig.config debug option now you can a variable in a structured format in the frontend by using a simple line of code in the Twig file.

{{ dump(my_variable) }}

3. Disable Twig cache

Once the Twig debug option is enabled then you can also enable auto_reload and disable twig cache.

You can read more about Twig debugging here.

parameters:
    twig.config:
        debug: true
        auto_reload: true
        cache: false

More configs you should change…

1. Disable CSS and JS aggregation on the local environment in Drupal 8 by uncommenting the below lines to settings.local.php.

$config['system.performance']['css']['preprocess'] = FALSE;
$config['system.performance']['js']['preprocess'] = FALSE;

2. Disable Drupal 8 render cache and dynamic page caching by uncommenting the below lines to settings.local.php.

$settings['cache']['bins']['render'] = 'cache.backend.null';
$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';

3. If you are using the Drupal version greater than 8.4 then do add the following line in the settings.local.php file.s

$settings['cache']['bins']['page'] = 'cache.backend.null';

4. In the settings.local.php file uncomment the following line to enable the null cache service in Drupal 8.

$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/development.services.yml';

Enable Drupal debugging with Drupal Console

If everything mentioned earlier is too much for you and you got access to Drupal Console then a single one-liner command can do the trick for you.

drupal site:mode dev

This Drupal console command will make changes in Drupal 8 configurations such as system.performance, views.settings, and system.logging to enable debugging. Command also makes changes to sites/default/services.yml file related to twig.config for frontend debugging.

And once you are done debugging the Drupal site you can revert all configurations back by running another command.

drupal site:mode prod

And the good part is this also rebuilds the cache at the end.

Conclusion

Debugging a Drupal site is not easy but with the right tools and tricks, you can make Drupal give you more information about the errors. And this information can help to debug the error better and faster.

NOTE: Make sure to clear the cache on your Drupal site after all the changes you have done for the local environment development.

WARNING: Make sure to not enable all these settings on the production site, unless you need to ;)

Понравилась статья? Поделить с друзьями:
  • Drugs activated ошибка
  • Dropbox при выполнении вашего запроса возникла ошибка
  • Dropbox ошибка при установке
  • Drone health ошибка
  • Droidcam ошибка connect failed please try again