0

In my wp-config.php, I have:

// 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);

However, the debug.log file is empty. It wasn't being created so I created it and then set its permissions to 666, yet it remains empty. Can anyone help me?

0

I use a plugin for this issue. Even if debug is set to false, it still prints error to the screen in red.

It is easy and fast to create the plugin.

  • In your plugins folder in your wordpress install, create a new file and call it anything you like, for instance, debugger-plugin.php.

  • Open up your newly created file, and paste the following code in there and save it. (this code comes from this post on code.tutsplus.com/

    <?php
    /*
    Plugin Name: Debugger Plugin
    */
    function admin_alert_errors($errno, $errstr, $errfile, $errline){
    
        $errorType = array (
             E_ERROR                            => 'ERROR',
             E_CORE_ERROR           => 'CORE ERROR',
             E_COMPILE_ERROR        => 'COMPILE ERROR',
             E_USER_ERROR           => 'USER ERROR',
             E_RECOVERABLE_ERROR  => 'RECOVERABLE ERROR',
             E_WARNING              => 'WARNING',
             E_CORE_WARNING         => 'CORE WARNING',
             E_COMPILE_WARNING      => 'COMPILE WARNING',
             E_USER_WARNING         => 'USER WARNING',
             E_NOTICE               => 'NOTICE',
             E_USER_NOTICE          => 'USER NOTICE',
             E_DEPRECATED                   => 'DEPRECATED',
             E_USER_DEPRECATED      => 'USER_DEPRECATED',
             E_PARSE                => 'PARSING ERROR'
        );
    
        if (array_key_exists($errno, $errorType)) {
            $errname = $errorType[$errno];
        } else {
            $errname = 'UNKNOWN ERROR';
        }
    ob_start();?>
    <div class="error">
      <p>
        <strong><?php echo $errname; ?> Error: [<?php echo $errno; ?>] </strong><?php echo $errstr; ?><strong> <?php echo $errfile; ?></strong> on line <strong><?php echo $errline; ?></strong>
      <p/>
    </div>
    <?php
    echo ob_get_clean();
    }
    
    set_error_handler("admin_alert_errors", E_ERROR ^ E_CORE_ERROR ^ E_COMPILE_ERROR ^ E_USER_ERROR ^ E_RECOVERABLE_ERROR ^  E_WARNING ^  E_CORE_WARNING ^ E_COMPILE_WARNING ^ E_USER_WARNING ^ E_NOTICE ^  E_USER_NOTICE ^ E_DEPRECATED    ^  E_USER_DEPRECATED    ^  E_PARSE );
    
  • You can now activate your debugger plugin from the back-end whenever you want. No need to make changes to wp-config.php :-)

|improve this answer|||||
  • I'm on a live site, so I need to send php error reports a log of some sort. Also, I added and activated this plugin but it did not show php errors on the page. – Murgittroyd Aug 25 '14 at 18:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.