Aquesta pàgina forma part de la documentació de Moodle en català, tot i que no ha estat traduïda encara. Podeu contribuir obertament a les tasques de traducció. Podeu consultar la Guia d'edició de la documentació i també participar ens els debats del fòrum de traductors de la documentació a moodle.org

Debugging: diferència entre les revisions

De MoodleDocs
Salta a:navegació, cerca
m (added link to spanish translation of page)
 
(28 revisions intermèdies per 9 usuaris que no es mostren)
Línia 1: Línia 1:
Location: ''Administration > Server > Debugging''
{{Developer tools}}
Debugging messages can be enabled by an administrator in ''Settings > 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 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.  


==How to turn on debugging==
==Debugging settings==
Here are the settings on the Debugging page:


Go into the admin screens, and look under Administration > Server > Debugging (In Moodle 2.0 it is Site administration ▶ Development ▶ Debugging). Set the...
===Debug messages===
The default is none, your choices are:


* '''Debug messages''' to '''ALL''', and  
;NONE : Do not show any errors or warnings (Default)
* '''Display debug messages''' to '''Yes'''.
;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


(You '''must''' do both). There is rarely any advantage in going to Developer level, unless you are a developer, in which case it is strongly recommended.
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, you are recommended to turn debugging back off again.
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.


==Debug messages==
===Display debug messages===
 
{{Moodle 1.7}}From Moodle 1.7 onwards, further options are provided for controlling how to handle PHP error messages. The administrator can select the types of error messages to be displayed or logged.
 
The options for debugging include:
* NONE: Do not show any errors or warnings
* MINIMAL: Show only fatal errors
* NORMAL: Show errors, warnings and notices
* ALL: Show all reasonable PHP debug messages. When you want to find the cause of a problem with your site, this is probably best the setting to use.
* DEVELOPER: extra Moodle debug messages for developers - If you turn this on, then PHP's error_reporting will be increased so that more warnings are printed.  This is almost essential for developers, but not very helpful for anyone else.
 
==Display debug messages==


There is an option to choose whether to display error messages or simply record them in the server logs.
There is an option to choose whether to display error messages or simply record them in the server logs.


==Debug email sending==
===Debug email sending===


Determines whether or not to enable verbose debug information during sending of email messages to SMTP server.
Determines whether or not to enable verbose debug information during sending of email messages to SMTP server.


==Performance info==
===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.
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.
Línia 45: Línia 40:
</code>
</code>
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!
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 translators.
===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==
==What to do if you cannot get to the admin screens==
Línia 56: Línia 60:
===In config.php===
===In config.php===


In moodle/config.php you can add the lines:
In [[Configuration file|config.php]] you can add the lines:


<code php>
<code php>
Línia 70: Línia 74:
</code>
</code>


For Moodle 2.0 the possible settings are as follows:
Possible settings are as follows:


<code php?
<code php>
// Force a debugging mode regardless the settings in the site administration
// Force a debugging mode regardless the settings in the site administration
// @error_reporting(1023);  // NOT FOR PRODUCTION SERVERS!
// @error_reporting(1023);  // NOT FOR PRODUCTION SERVERS!
@ini_set('display_errors', '1'); // NOT FOR PRODUCTION SERVERS!
@ini_set('display_errors', '1'); // NOT FOR PRODUCTION SERVERS!
$CFG->debug = 38911; // DEBUG_DEVELOPER // NOT FOR PRODUCTION SERVERS!
$CFG->debug = 32767;         // DEBUG_DEVELOPER // NOT FOR PRODUCTION SERVERS!
// for Moodle 2.0 - 2.2, use:  $CFG->debug = 38911; 
$CFG->debugdisplay = true;  // NOT FOR PRODUCTION SERVERS!
$CFG->debugdisplay = true;  // NOT FOR PRODUCTION SERVERS!


Línia 107: Línia 112:
==See also==
==See also==


* Using Moodle [http://moodle.org/mod/forum/discuss.php?d=91031 Debugging Turned on to Developer Mode on 1.8.2] forum discussion including instructions on how to turn debugging off
* Developers can also use [http://xdebug.org/ XDEBUG] (Installed as a module on the Apache server) to further dig into the code, step by step using an [http://xdebug.org/docs/remote XDEBUG client application]. Probably, as part of their favorite IDE. For example: [http://php.netbeans.org/ NetBeans], [http://www.jetbrains.com/phpstorm/ phpStorm] or...
 
[[Category:Administrator]]


[[es:Depuración]]
[[fr:Débogage]]
[[fr:Débogage]]

Revisió de 18:34, 12 març 2013

Debugging messages can be enabled by an administrator in Settings > 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 translators.

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 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 add the lines:

$CFG->debug = 2047; $CFG->debugdisplay = 1;

Or even more debugging messages:

$CFG->debug = 6143; $CFG->debugdisplay = 1;

Possible settings are as follows:

// Force a debugging mode regardless the settings in the site administration // @error_reporting(1023); // NOT FOR PRODUCTION SERVERS! @ini_set('display_errors', '1'); // NOT FOR PRODUCTION SERVERS! $CFG->debug = 32767; // DEBUG_DEVELOPER // NOT FOR PRODUCTION SERVERS! // for Moodle 2.0 - 2.2, use: $CFG->debug = 38911; $CFG->debugdisplay = true; // 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 remove those lines again when you have finished diagnosing your problem.

In the database

Using a tool like phpMyAdmin, execute the following SQL commands:

UPDATE mdl_config SET value = 2047 WHERE name = 'debug'; UPDATE mdl_config SET value = 1 WHERE name = 'debugdisplay';

To turn it back off, use the admin screens, or the commands:

UPDATE mdl_config SET value = 0 WHERE name = 'debug'; UPDATE mdl_config SET value = 0 WHERE name = 'debugdisplay';

(If you use a different database prefix, you will need to adjust those commands accordingly.)

See also