跳到正文
工具

WP_DEBUG Configurator

Turn on the debug log without breaking your live site

在你的浏览器里运行。什么都不上传。

Where is this site?

This changes the recommendation, not just the wording. The safe configuration on a live site is genuinely different from the useful one on your laptop.

Verdict

Options
wp-config.php

Paste these ABOVE the line that says /* That's all, stop editing! */ — anything below it is ignored, which is why so many people report that WP_DEBUG 'does nothing'.

关于WP_DEBUG Configurator

Generate the WP_DEBUG constants that write errors to a log file instead of printing them to your visitors. The default WP_DEBUG snippet most sites copy will display PHP errors publicly — this one will not.

FAQ

常见问题

在正在运行的站点上开启 WP_DEBUG 安全吗?

只有在把 WP_DEBUG_DISPLAY 设为 false 时才安全。单独开启时,WP_DEBUG 会把 PHP 通知和警告——包括你服务器的绝对文件路径——直接打印到访客加载的页面里。几乎每一篇教程都甩给你那一行就没了。把它和 WP_DEBUG_LOG 以及 WP_DEBUG_DISPLAY false 配在一起,它才是安全的。

WordPress 的调试日志会写到哪里?

默认写到 wp-content/debug.log。值得知道的是:在很多主机上,这个文件是可以被公开获取的——任何人都能在浏览器里请求它。你可以给 WP_DEBUG_LOG 传一个路径,把日志写到 Web 根目录之上,这个工具会帮你生成。

我把 WP_DEBUG 设成了 true,但什么都没发生。为什么?

几乎总是因为这个常量被加在了 wp-config.php 里 “That's all, stop editing!” 那一行的下面。那一行之后的所有内容都会被忽略。把它移到上面去。