Debugging Errors on WordPress & Viewing Logs

 


With SSH/terminal access:

SSH into the VPS via Terminal

Then run the command below to view most recent PHP errors:

$ pagely error:php ~/sites/sitename.com

To tail the error log live, as errors are occurring:

$ pagely error:php ~/sites/sitename.com --follow

Then reload the error page in the browser & the terminal output should show the line.


With sFTP access only:

Add the following code to the top of the wp-config.php file.

define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);

The error log will then be viewable in a browser at the http://sitename.com/wp-content/debug.log URL, or through sFTP at the /wp-content/debug.log location.

  • When finished debugging:
    • Comment or remove the lines added above to the wp-config.php file.
    • The system will automatically remove the debug.log file for you shortly after so you don’t need to worry about it.
    • If you are concerned with leaving this available since it is publicly accessible you can delete the /wp-content/debug.log file through sFTP.

Bypassing our error page:

We cannot disable the error page, but you can bypass it to see what errors are poping up.

Add the following code to the top of the wp-config.php file:

if (false !== strpos($_SERVER['REQUEST_URI'], 'debug')) {
    define('WP_DEBUG', true);
}

To view the error, add /?debug to the end of the URL that’s erroring out.