How to turn on debugging and log the messages in WordPress

You can enable WordPress debug without displaying the messages publicly to the site visitors.

You can enable WordPress debug in WordPress by adding:

define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define( 'WP_DEBUG_DISPLAY', false );
ini_set('error_reporting', E_ALL);

to the wp-config.php file. 

WordPress debug messages are logged without displaying to your site visitors. After the issue is resolved, you can turn debugging off by chaninging the line define(‘WP_DEBUG’, true) to define(‘WP_DEBUG’, false);

You can find wp-config.php in your WordPress directory and copy and paste the 3 lines above in that file.

Please make sure none of the lines above are repeated in the file.

You can then find the debug.log file in the WordPress wp-content directory.