从权限问题到PHP问题,WordPress中可能发生多种类型的错误。这些可能很难在您的网站上诊断,尤其是如果您没有技术背景。

为了简化监视和诊断这些错误的过程,您可以在WP-Config文件中设置WordPress错误日志。这wp-config.php file是一个核心WordPress文件,其中包含您网站的基本配置详细信息。此信息允许WordPress连接到您的数据库,生成确保网站安全的身份验证密钥,等等。

By adding a few lines of code, you turn your wp-config.php file into a debugging tool that automatically finds and logs errors on your site. In the error logs, you can identify the plugin, script, or code that is causing errors. You can then troubleshoot these issues yourself or reach out to WordPress support.

Monitoring your site in this way can help you identify and resolve issues before they disrupt your data transfer capacity, negatively impact the visitor experience, or cause downtime.

为了帮助您保持站点顺利运行,让我们浏览WP-Config文件中设置错误日志的过程。

使用HubSpot的WordPress网站来发展业务

如何在WP-Config文件中设置WordPress错误日志

要在wp-config.php文件中设置WordPress错误日志,您只需要在文件中添加几行代码即可。

这是一个简单的过程,但是作为最佳实践,您应始终在编辑之前副本副本的wp-config.php文件。那是因为即使文件中的一个小错误也可能使您的网站无法访问。

首先,请登录您的控制面板并打开文件管理器。找到wp-config.php文件,然后右键单击以复制它。重命名文件wp-config.php.backup。

Now that you have a backup, right-click the original wp-config.php file. Click the编辑option.

右键单击wp-config.php文件,然后单击“编辑”选项

Source

向下滚动到文件的末尾到读取 /*的行,请停止编辑!愉快的博客。*/

就在此行之前,您可能会看到以下代码行:Define('WP_DEBUG',false);

If you do, delete it then copy and paste the following lines of code:

定义('wp_debug',true);

define('wp_debug_log',true);

define('wp_debug_display',false);

@ini_set('display_errors',0);

保存您的更改。您网站的“调试模式”现在将打开,所有错误都将保存到您的 / wp-content / Directory中的debug.log日志文件中。

错误和警告也将隐藏在您网站的前端。通过隐藏访问者的这些错误和警告消息,您将帮助确保它们在您的网站上具有无缝的体验。

查看您的WordPress错误日志

To review your error logs, navigate to your /wp-content/ folder in your File Manager. Locate the debug.log file.

导航到您的文件管理器中的 / wp-content /文件夹,然后找到debug.log文件

Source

该文件将包含所有WordPress错误,警告和已记录的通知。请注意,只有遇到任何错误,您才会看到此文件。

debug.log文件将包含已记录的所有WordPress错误,警告和通知

Source

在这一点上,您可以尝试自行解决问题,因为WordPress日志可以通过将元素命名为故障来帮助您了解导致错误的原因。您也可以联系WordPress支持寻求帮助。确保从错误日志中分享文本,这将有助于支持REP了解问题并为您提供解决方案。

你现在都做过了!错误日志自动on your site, you’ll be able to keep track of errors that occur on your site more easily. This monitoring can help you quickly resolve any issues before they damage your site’s reputation or your visitors’ experience.

Use HubSpot tools on your WordPress website and connect the two platforms  without dealing with code. Click here to learn more.

Use HubSpot tools on your WordPress website and connect the two platforms  without dealing with code. Click here to learn more.

最初发布于2019年12月3日12:24:58 PM,更新于9月1日2021年更新

主题:

WordPress网站