How to enable debug.log logging and yet disable PHP warning logs

[ad_1]

I need logging to run but need to suppress warning logs. I tried a few tutorials online and none worked, such as https://wp-umbrella.com/troubleshooting/turning-off-php-errors-in-wordpress/ and adding the below in wp-config.php

error_reporting(E_ALL & ~E_WARNING & ~E_NOTICE);

[ad_2]
2 Comments
  1. // Enable WP_DEBUG mode
    define( ‘WP_DEBUG’, true );

    // Enable error logging to /wp-content/debug.log
    define( ‘WP_DEBUG_LOG’, true );

    // Disable display of errors and warnings
    define( ‘WP_DEBUG_DISPLAY’, false );
    @ini_set( ‘display_errors’, 0 );

    // Set error reporting to exclude warnings
    @ini_set( ‘error_reporting’, E_ALL & ~E_WARNING );
    error_reporting( E_ALL & ~E_WARNING );

    If that’s not working, you are probably unable to override your php.ini configuration file. Check with your host and either have them update php.ini or have them provide documentation on how you can do so. Then you’ll need to adjust the *error_reporting* line there.

  2. Try this:

    define(‘WP_DEBUG’, true);
    define(‘WP_DEBUG_LOG’, true);
    define(‘WP_DEBUG_DISPLAY’, false);
    @ini_set(‘display_errors’, 0);
    error_reporting(E_ALL & ~E_WARNING & ~E_NOTICE);

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer