简体   繁体   中英

Php errors not logging for wordpress plugins

When I have a php error in a wordpress plugin or theme on my localhost, it doesn't output to my Apache error log.

This is not the case for php files that I have in my www/ directory; those seem to log just fine, as do errors from the wordpress core. This also seems to be the case on other servers as well.

Any thoughts as to what might be causing this?

As the Codex says:

WP_DEBUG_LOG is companion to WP_DEBUG that causes all errors to also be saved to a debug.log log file inside the /wp-content/ directory. This is useful if you want to review all notices later or need to view notices generated off-screen (eg during an AJAX request or wp-cron run).

Edit your wp-config.php file and add the following definition (if not already present):

define('WP_DEBUG_LOG', true);

This will make Wordpress log the errors to /wp-content/debug.log .

However, if you want to change the location of the debug.log file, you can use the following work-around:

if (defined('WP_DEBUG_LOG') && WP_DEBUG_LOG) {
    ini_set( 'error_log', WP_CONTENT_DIR.'/foo/debug.log' ); //modify accordingly
}

Hope this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM