If error messages and warning are essential during development. They are not welcome in your production environment.
We will have a look on how to hide warnings and error messages from the public while keeping this information accessible to the admin (see https://codex.wordpress.org/Editing_wp-config.php#Debug ) .
Method one: wp-config.php and php.ini
First we will have a look at the wp-config.php file. For this you will need an ftp access to your site.
https://codex.wordpress.org/Editing_wp-config.php#Debug
You will also need access to php.ini
Method 2: wp-config.php only
Replace:
define(
'WP_DEBUG'
, false);
by:
ini_set
(
'log_errors'
,
'On'
);
ini_set
(
'display_errors'
,
'Off'
);
ini_set
(
'error_reporting'
, E_ALL );
define(
'WP_DEBUG'
, false);
define(
'WP_DEBUG_LOG'
, true);
define(
'WP_DEBUG_DISPLAY'
, false);
Source: https://www.templatemonster.com/help/wordpress-how-to-hide-php-warnings-and-notices.html
With this method nothing is logged (at least on my server).
For a debug friendly version use Method 3:
// Enable WP_DEBUG mode define( 'WP_DEBUG', true ); // Enable Debug logging to the /wp-content/debug.log file define( 'WP_DEBUG_LOG', true ); // Disable display of errors and warnings define( 'WP_DEBUG_DISPLAY', false ); @ini_set( 'display_errors', 0 ); // Use dev versions of core JS and CSS files (only needed if you are modifying these core files) define( 'SCRIPT_DEBUG', true );
Source: https://codex.wordpress.org/Debugging_in_WordPress
Message are off and error are logged. The draw back of this methods is that the logs are public at /wp-content/debug.log