PHP error logs

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'?>' only):
 ini_set ('display_errors', 'on');
 ini_set ('log_errors', 'on');
 ini_set ('display_startup_errors', 'on');
 ini_set ('error_reporting', E_ALL);
 $CFG->debug = DEBUG_ALL;
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.

See also

Personal tools
User docs (English)