How to display only specific Error types in debug.log? No notices, warnings, etc

I can't find the right way to make it work. I tried many things, like putting this in wp-config.php

define('WP_DEBUG', true);
define('WP_DEBUG_DISPLAY', false);
define('WP_DEBUG_LOG', 'wp-content/themes/mytheme/mylog.log' ); // yeah, customized it a bit. It logs everything
ini_set('error_reporting', E_ERROR );

also tried to set it in the php.ini on various websites i manage. Not on managed hosting. Or at least not on the well known international ones. Can it be server side or syntax error, or not even possible what i want?

Thanks!

Topic notices wp-debug php debug Wordpress

Category Web


In short: this is the most detailed documentation on the topic (most likely..)
The only source you need.

Oh, and here is an amazing Php Error Level calculator to set up the php error mask binary code fast (if needed)

Based on this, i made my custom error reporting:

In functions.php

function error_report_log_customize(){
    // error_reporting(E_ALL);
    // error_reporting(E_NOTICE);
    // error_reporting(E_ALL & ~E_DEPRECATED & ~E_NOTICE);
    error_reporting(E_ALL & ~E_DEPRECATED & ~E_NOTICE & ~E_WARNING);

    // helpful tool https://maximivanov.github.io/php-error-reporting-calculator/
}
add_action('init','error_report_log_customize');

In wp-config.php

define('WP_DEBUG', true);
define('WP_DEBUG_LOG', 'wp-content/themes/my-theme/my-logfile.log');
define('WP_DEBUG_DISPLAY', false);

Only thing I'm not 100% sure about which hook is the best for this. init seems working so far, but anyone with better insight, pls comment.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.