Debugging: Difference between revisions
Harry Smith (talk | contribs) |
|||
(9 intermediate revisions by 7 users not shown) | |||
Line 42: | Line 42: | ||
===Show origin of language strings=== | ===Show origin of language strings=== | ||
Helps | |||
Helps with [[:dev:Translation|translation]] and also with [[Language customization]]. Sometimes <code>?strings=1</code> should be added; other times <code>&strings=1</code>. See the Wikipedia article [http://en.wikipedia.org/wiki/Query_string Query string] for details. | |||
===Show validator links=== | ===Show validator links=== | ||
Line 56: | Line 57: | ||
===Try typing the URL directly=== | ===Try typing the URL directly=== | ||
The debug settings are at the URL <code><nowiki>http://.../admin/settings.php?section=debugging</nowiki></code> on your server. Sometimes that URL will work, even though the pages you need to go | The debug settings are at the URL <code><nowiki>http://.../admin/settings.php?section=debugging</nowiki></code> on your server. Sometimes that URL will work, even though the pages you need to go to get there (for example the site front page) do not. So it is worth trying to enter that URL directly. | ||
===In config.php=== | ===In config.php=== | ||
In [[Configuration file|config.php]] you can | In [[Configuration file|config.php]] you can uncomment lines (delete the // at the start of the line) under Section 7 to enable debugging for all or just specific users: | ||
<code php> | <code php> | ||
$CFG->debug = (E_ALL | E_STRICT); | //========================================================================= | ||
$CFG->debugdisplay = 1; | // 7. SETTINGS FOR DEVELOPMENT SERVERS - not intended for production use!!! | ||
//========================================================================= | |||
// | |||
// Force a debugging mode regardless the settings in the site administration | |||
// @error_reporting(E_ALL | E_STRICT); // NOT FOR PRODUCTION SERVERS! | |||
// @ini_set('display_errors', '1'); // NOT FOR PRODUCTION SERVERS! | |||
// $CFG->debug = (E_ALL | E_STRICT); // === DEBUG_DEVELOPER - NOT FOR PRODUCTION SERVERS! | |||
// $CFG->debugdisplay = 1; // NOT FOR PRODUCTION SERVERS! | |||
// | |||
// You can specify a comma separated list of user ids that that always see | // You can specify a comma separated list of user ids that that always see | ||
// debug messages, this overrides the debug flag in $CFG->debug and $CFG->debugdisplay | // debug messages, this overrides the debug flag in $CFG->debug and $CFG->debugdisplay | ||
// for these users only. | // for these users only. | ||
$CFG->debugusers = '2 | // $CFG->debugusers = '2'; | ||
</code> | </code> | ||
Remember to comment those lines again (reinsert the // at the start of the line) when you have finished diagnosing your problem. | |||
'''NOTE 1''': do not try to modify the config database table directly, it will not work because the values are cached in MUC. | |||
( | '''NOTE 2''': if you find your config.php does not have the above settings (you have a cut down approx 30 lines config.php) look for a "config-dist.php" file that contains the full details. I would suggest transferring your details in the current config.php file you have into the full config file and renaming that one to "config.php". | ||
==See also== | ==See also== |
Latest revision as of 16:09, 7 April 2015
Debugging messages can be enabled by an administrator in Administration > Site administration > Development > Debugging.
Debugging messages are intended to help diagnose problems and/or help Moodle developers. If you have a problem with your Moodle site and ask for help in a Moodle.org forum, a developer may ask you to turn debug messages on, in order to locate the cause of the problem. By default Moodle does not show any error messages at all. If you are having problems (e.g. blank screens or incomplete screens) turning on debugging is usually the first thing to try.
Debugging settings
Here are the settings on the Debugging page:
Debug messages
The default is none, your choices are:
- NONE
- Do not show any errors or warnings (Default)
- ALL
- Show all reasonable PHP debug messages
- MINIMAL
- Show only fatal errors
- NORMAL
- Show warnings, errors and notices
- DEVELOPER
- extra Moodle debug messages for developers
There is rarely any advantage in going to Developer level, unless you are a developer, in which case it is strongly recommended.
Once you have got the error message, and copied and pasted it somewhere. HIGHLY RECOMMENDED to turn Debug back to NONE. Debug messages can give clues to a hacker as to the setup of your site.
Display debug messages
There is an option to choose whether to display error messages or simply record them in the server logs.
Debug email sending
Determines whether or not to enable verbose debug information during sending of email messages to SMTP server.
Performance info
The Performance info option determines whether performance info will be included in the footer of the standard theme (and some other themes). Performance info includes the time for the page to load, the amount of memory used to generate the page, cpu usage, load, and the record cache hit/miss ration.
If you add
define('MDL_PERF', true);
define('MDL_PERFDB', true);
define('MDL_PERFTOLOG', true);
define('MDL_PERFTOFOOT', true);
to your config.php file, then it will also count database queries. (This has to be in config.php, because Moodle starts doing DB queries before it loads the config information in the database!
Show origin of language strings
Helps with translation and also with Language customization. Sometimes ?strings=1
should be added; other times &strings=1
. See the Wikipedia article Query string for details.
Show validator links
Be careful, read the warning.
Show page information
To show page information printed in the page footer.
What to do if you cannot get to the admin screens
If the error is stopping you even getting to the admin screens to turn on debugging, then you can set the debugging setting manually.
Try typing the URL directly
The debug settings are at the URL http://.../admin/settings.php?section=debugging
on your server. Sometimes that URL will work, even though the pages you need to go to get there (for example the site front page) do not. So it is worth trying to enter that URL directly.
In config.php
In config.php you can uncomment lines (delete the // at the start of the line) under Section 7 to enable debugging for all or just specific users:
//=========================================================================
// 7. SETTINGS FOR DEVELOPMENT SERVERS - not intended for production use!!!
//=========================================================================
//
// Force a debugging mode regardless the settings in the site administration
// @error_reporting(E_ALL | E_STRICT); // NOT FOR PRODUCTION SERVERS!
// @ini_set('display_errors', '1'); // NOT FOR PRODUCTION SERVERS!
// $CFG->debug = (E_ALL | E_STRICT); // === DEBUG_DEVELOPER - NOT FOR PRODUCTION SERVERS!
// $CFG->debugdisplay = 1; // NOT FOR PRODUCTION SERVERS!
//
// You can specify a comma separated list of user ids that that always see
// debug messages, this overrides the debug flag in $CFG->debug and $CFG->debugdisplay
// for these users only.
// $CFG->debugusers = '2';
Remember to comment those lines again (reinsert the // at the start of the line) when you have finished diagnosing your problem.
NOTE 1: do not try to modify the config database table directly, it will not work because the values are cached in MUC.
NOTE 2: if you find your config.php does not have the above settings (you have a cut down approx 30 lines config.php) look for a "config-dist.php" file that contains the full details. I would suggest transferring your details in the current config.php file you have into the full config file and renaming that one to "config.php".
See also
- Developers can also use XDEBUG (Installed as a module on the Apache server) to further dig into the code, step by step using an XDEBUG client application. Probably, as part of their favorite IDE. For example: NetBeans, phpStorm or...