打开在 wp-config.php 文件,添加以下代码(注意如果原配置文件中有define('WP_DEBUG', true);等代码,请把它们注释掉):
/**
* This will log all errors notices and warnings to a file called debug.log in
* wp-content (if Apache does not have write permission, you may need to create
* the file first and set the appropriate permissions)
*/
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors',0);
保存后,你就可以在 wp-content/debug.log 文件中看到相应的错误信息了。如果你想直接显示错误信息在网页上,替换成:
/ 开启WP_DEBUG模式
define( 'WP_DEBUG', true );
// 开启DEBUG日志,一定要记得关闭这个日志功能并清理这个日志文件哦,产生的日志文件在: /wp-content/debug.log
define( 'WP_DEBUG_LOG', true );
// 显示errors and warnings
define( 'WP_DEBUG_DISPLAY', true );
@ini_set( 'display_errors', 'On' );
最后,测试完成后一定要注释掉或者删除以上代码,以防坏人!