WordPress上的调试日志不起作用 [英] Debug logs at wordpress not working

查看:112
本文介绍了WordPress上的调试日志不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想启用wordpress网站的调试日志,在wp-config.php中添加以下设置

I would like to enable debug logs of wordpress site, added following setting at wp-config.php

/* WordPress debug mode for developers. */
define('WP_DEBUG', true);
if (WP_DEBUG) {
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors', 0);
}

在wp-content文件夹下创建了debug.log文件.

created debug.log file under wp-content folder.

更新了777的wp内容以及debug.log.

updated 777 on wp-content as well as debug.log..

但是文件仍然是空白的..

But still file is blank..

请让我知道如何解决...

Please let me know how can I fix it...

我只是想调试站点,有时主页会无限循环.浏览器未加载页面..CPU达到100%...

Just I would like to debug the site, some times home page going in infinite loop..i.e. browser not loading the page.. CPU goes to 100%...

谢谢

推荐答案

您有@ini_set('display_errors', 0);-它会告诉PHP(不是WordPress)停止显示错误. WordPress要求打开错误才能将其传递到适当的位置. define('WP_DEBUG_DISPLAY', false);define('WP_DEBUG', false);应该注意将它们隐藏在前端.

You have @ini_set('display_errors', 0); - which will tell PHP (not WordPress) to stop displaying errors. WordPress requires errors to be turned on in order for it to pass them to the appropriate place. define('WP_DEBUG_DISPLAY', false); or define('WP_DEBUG', false); should take care of hiding them on the front end for you.

此外,您只需要定义常量,就不必创建IF语句.您实际上要说的是打开错误报告.现在,如果打开错误报告,请执行此操作." -尽管从逻辑上讲是正确的,但它很冗长.只需将WP_DEBUG常量定义为true就足够了,因为WordPress会完成其余的工作.

Also, you should only need to define the constants, the IF statement you've created isn't necessary. What you're essentially saying there is "Turn on error reporting. Now, if error reporting is turned on, do this." - although logically correct, it's verbose. Simply defining the WP_DEBUG constant as true should be enough, as WordPress will do the rest of the work.

此外-如果wp_debug.log不存在-WordPress会为您创建它(具有正确的权限),前提是它具有在您的服务器上执行此操作的权限(在大多数情况下,这是正确的).所以-您不需要更改wp-content的CHMOD值或它的孩子.我建议您将其更改为WordPress的推荐值(文件夹为755,文件为644)-CHMOD值为777绝对很困难.

Also - if wp_debug.log doesn't exist- WordPress will create it for you (with the correct permissions), assuming it has permission to do so on your server (in most cases this will be true). So - you shouldn't need to change the CHMOD values of wp-content or it's children. I'd advise you to change them to WordPress' recommended values (755 for folders, and 644 for files) - as a CHMOD value of 777 is pretty foolhardy to have.

您只需要以下内容:

define('WP_DEBUG', true); // Turn on WP Debugging
define('WP_DEBUG_LOG', true); // Log errors to wp_debug.log
define('WP_DEBUG_DISPLAY', false); // Turns off error reporting on the front end

这篇关于WordPress上的调试日志不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆