Moodle журнал ошибок

From MoodleDocs

Jump to:navigation, search

PHP can be set up to log errors in a variety of different ways: two of these involve the use of the php.ini file and the ini_set command.

How to enable and check PHP error logs

PHP can be set up to log errors in a variety of different ways: two of these involve the use of the php.ini file and the ini_set command.

  • Using the php.ini file: The log settings are contained in the php.ini file stored on the server. If you don’t know where that is, edit your Moodle config.php and add the following as the second line
 phpinfo();
then reload the web page. Look for the entry Configuration File (php.ini) Path.
When you have located php.ini open it in your favorite text editor. Find the Error handling and logging section of the php.ini file. Make sure that both display_errors = On, display_startup_errors = On and log_errors = On are present and uncommented. Check the value of error_log — this tells you the location of the file errors are logged to. If it is commented out then errors will be sent to the web server error log file. Remember, if you make any changes to this file you will need to restart the web server (or just reboot the server).
  • Using ini_set commands: If you are using Moodle 1.7 or higher, the previous steps are not enough. In those versions error logging parameters are dependant on certain administrative settings that you specify in the debugging section. The problem is that if you can’t access the administrative pages, you can’t set the debugging options. So the only way to modify them is by adding the following lines to your config.php file, just before the last line (the one containing a single’?>’ , if present):
 ini_set ('display_errors', 'on');
 ini_set ('log_errors', 'on');
 ini_set ('display_startup_errors', 'on');
 ini_set ('error_reporting', E_ALL);
 $CFG->debug = 30719; // DEBUG_ALL, but that constant is not defined here.
This will enable the same settings specified above even if Moodle sets them otherwise.
Important: Remember to put them just before the last line of config.php.

Debug Mode for version 3.9:
@error_reporting(E_ALL | E_STRICT);
@ini_set(‘display_errors’, ‘1’);
$CFG->debug = (E_ALL | E_STRICT);
$CFG->debugdisplay = 1;

Error Logs

The default settings of the PHP Error Log file varies from OS to OS. The location of the error log file itself can be set manually in the php.ini file. On a Windows server, in IIS, it may be something like «‘error_log = C:\log_files\php_errors.log'» in Linux it may be a value of «‘/var/log/php_errors.log'». The php_errors.log file may be required to be manually created, which would mean that the ownership and rw permissions will need to be set accordingly.

See also

  • Installing Moodle
  • Installation FAQ

Дано: система электронного обучения Moodle 3.2.
Задача: включить режим отображения ошибок (режим отладки).

Когда в системе Moodle происходит ошибка или система ведет себя не стандартно, зачастую определить причину помогает режим, при котором на страницах системы будут выводиться подробные сообщения об ошибках.

Допустим, появляется такое сообщение об ошибке:
Ошибка чтения базы данных

Нажатие на ссылку «Подробнее об этой ошибке» ведет на документацию на официальном сайте Moodle и не дает представления о конкретной причине произошедшего.
Теперь включим отладки. Для этого переходим в администрирование сайта, раздел «Разработка» — «Отладка»:

На открывшейся странице в блоке «Отладочные сообщения» (debug) выбираем режим «Разработчик: дополнительные сообщения отладчика Moodle»:

Сохраняем и снова переходим на страницу, где возникала ошибка. Теперь видим подробное сообщение о том, что действительно случилось, что может позволить быстрее решить возникшую проблему:

Для отключения режима вывода сообщений об ошибках делаем всё с точностью до наоборот. В настройках отладки выбираем режим «Нет: не выводить никаких ошибок и предупреждений»:

Если Вам понравилась статья, пожалуйста, поставьте лайк, сделайте репост или оставьте комментарий. Если у Вас есть какие-либо замечания, также пишите комментарии.

I am a newbie to Moodle. I am trying to create a local plug which would do tasks (sending email) automatically when user is enrolled / unenrolled.

While developing this plugin, I am trying to echo or print_r some information for debug and tracing purposes.

The code is as simple as

function perform_enrol($eventdata){
        echo 'Hello World';
        print_r($eventdata);
        return true;
}

However, when the code executes, I get the following error occurs:

> Syntax Error File:
> http://192.168.10.60/moodle/theme/yui_combo.php?3.9.1/build/simpleyui/simpleyui.js&3.9.1/build/loader/loader.js
> Line: 18541

When I comment out the echo and print_r , the code works fine.
The same problem continues for print_object , debug or any other printing functions.

Is there a specific way to print from plugins. I have used these functions in core code in past and seems to work fine.

asked Aug 14, 2013 at 6:10

Nis's user avatar

When I’m debugging Moodle, I usually use error_log to print the message right to the error log of the web server (/var/log/apache2/error.log in a Debian-like distribution with Apache).

So, to inspect some variable, I need to use a function that return it as a string. Something like this:

error_log('My variable x is: ' . print_r($variable, true));

Or:

error_log('My variable x is: ' . var_export($variable, true));

Take a look at this question for more information: How can I capture the result of var_dump to a string?

Community's user avatar

answered Aug 15, 2013 at 7:55

franzlorenzon's user avatar

franzlorenzonfranzlorenzon

5,8456 gold badges36 silver badges58 bronze badges

This is not the issue with the debug message from the plugin. This is due to outputting a message before an Ajax request. Please check if there are any ajax request in the particular plugin or in Moodle default pages. There is no specific debug messages specific for plugins. You can use any php built in debug functions.

Hope this helps.

answered Aug 14, 2013 at 6:56

gnuwings's user avatar

gnuwingsgnuwings

9507 silver badges8 bronze badges

Moodle has logs that can be accessed at site and course level. Logs are activity reports that can be filtered by required fields such as day, participants, activity, action or site.

Site activity logs

To generate your own site activity logs, following the steps below. (Please note  you must have the administrator role)

1) Go to Settings > Site Administration > Reports > Logs
2) Select your desired logs by choosing options from dropdown lists

View Logs

3) Click “Get these logs” button to view the list of logs

Get Logs

This list of logs activity describe all the information about log time, user name, what event occurred, which page, description with key fields and which IP address was used.

In the bottom of the list, there is “Download” button. Choose an option from the dropdown list and select which format (Excel or text or html) you want to download. Then click the “Download” button and save the log report.

Download Logs

You can view all logs by clicking the page numbers at the bottom of the window.

When your Moodle stops working and you need to find out why, you can enable error reporting. A common reason for this is when the page comes up blank. Blank pages don’t show you what error is that causes the screen to go blank so you will need to enable errors in your Moodle config.php.

There are different types of error reporting you can enable to see why your Moodle stopped working. For more information on displaying errors for PHP, please see our tutorial on Display and log errors for PHP.

Steps to enable error reporting

  1. Login into your cPanel.
  2. Go to the File Manager. Select your Moodle directory and click Go.
  3. Edit the config.php Moodle

    Edit the config.php file with the code editor.

  4. Code view of config.php Moodle

    Paste the following code at the bottom of the page.

    ini_set ('display_errors', 'on'); ini_set ('log_errors', 'on'); ini_set ('display_startup_errors', 'on'); ini_set ('error_reporting', E_ALL);

    Save the file.

  5. View of PHP errors Moodle

    Now visit your site where you are having the problem and you should see the errors display. The snapshot to the right shows what the PHP errors will look like..

Понравилась статья? Поделить с друзьями:
  • Montair коды ошибок
  • Monster hunter rise неустранимая ошибка приложения
  • Miwe econo коды ошибок
  • Monopoly plus ошибка при запуске приложения msvcr110 dll
  • Mivue j60 ошибка карты памяти что делать