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

Do you want to set up WordPress error logs in wp-config file? The wp-config file in WordPress not only controls your WordPress site settings, it is also a very a useful debugging tool to help you find and fix errors. In this article, we will show you how to set up WordPress error logs in the wp-config file.

您是否要在wp-config文件中设置WordPress错误日志? WordPress中的wp-config文件不仅可以控制您的WordPress网站设置,它还是一个非常有用的调试工具,可帮助您查找和修复错误。 在本文中,我们将向您展示如何在wp-config文件中设置WordPress错误日志。

Setting up WordPress error logs
为什么以及何时需要在WP-Config中设置WordPress错误日志 (Why and When You Need to Set up WordPress Error Logs in WP-Config)

The wp-config.php file is a WordPress configuration file that contains important WordPress settings. These settings tell your website how to connect to your WordPress database, which database table prefix to use, and generates authentication keys to make your WordPress site more secure.

wp-config.php文件是一个WordPress配置文件,其中包含重要的WordPress设置。 这些设置告诉您的网站如何连接到WordPress数据库 ,要使用的数据库表前缀,并生成身份验证密钥以使WordPress网站更加安全。

To learn more about wp-config file, please see our article on how to edit wp-config file in WordPress.

要了解有关wp-config文件的更多信息,请参阅有关如何在WordPress中编辑wp-config文件的文章。

Apart from default WordPress settings, wp-config file can also be used to define several other parameters. It can also enable WordPress debugging mode and save WordPress error logs.

除了默认的WordPress设置外,wp-config文件还可用于定义其他几个参数。 它还可以启用WordPress调试模式并保存WordPress错误日志。

This helps you find WordPress errors by identifying the plugins or scripts that are causing them. You can then go ahead and find a fix for those WordPress errors.

这可以通过识别导致它们的插件或脚本来帮助您查找WordPress错误 。 然后,您可以继续查找这些WordPress错误的修复程序。

That being said, let’s take a look at how to enable and setup WordPress error logs in wp-config file.

话虽如此,让我们看一下如何在wp-config文件中启用和设置WordPress错误日志。

在WP-Config文件中设置WordPress错误日志 (Setting up WordPress Error Logs in WP-Config File)

First, you will need to edit your wp-config.php file. You can access it by connecting to your website using an FTP client or File Manager app in cPanel.

首先,您将需要编辑wp-config.php文件。 您可以使用cPanel中的FTP客户端或文件管理器应用程序连接到您的网站来访问它。

Edit wp-config file

You will find wp-config.php file in the root directory of your website. Open the file in any text editor and look for the line that says ‘That’s all, stop editing! Happy blogging.’

您将在网站的根目录中找到wp-config.php文件。 在任何文本编辑器中打开该文件,然后查找显示“仅此而已,停止编辑! 祝您博客愉快。”

Just before this line you need to add the following code:

在此行之前,您需要添加以下代码:


define( 'WP_DEBUG', true );

It is possible that this code is already in your wp-config.php file and is set to false. In that case, you just need to change it to true.

此代码可能已经在您的wp-config.php文件中,并被设置为false。 在这种情况下,您只需要将其更改为true。

This line alone will turn on WordPress debug mode. However the downside of using this debugging alone is that you will see WordPress errors and warnings inside your admin area as well as front page of your website.

仅此行将打开WordPress调试模式。 但是,单独使用此调试的缺点是,您将在管理区域以及网站首页中看到WordPress错误和警告

If you want errors to be logged, then you will also need to add the following code in your wp-config.php file just below the WP_DEBUG line.

如果要记录错误,则还需要在WP_DEBUG行下方的wp-config.php文件中添加以下代码。


define( 'WP_DEBUG_LOG', true );

Don’t forget to save your changes and upload your wp-config.php file back to your website.

不要忘记保存更改并将wp-config.php文件上传回您的网站。

查看您的WordPress错误日志 (Reviewing Your WordPress Error Logs)

First you need to visit your WordPress site and access the pages that were resulting in errors or warnings. After that, you will need to connect to your website using a FTP client or file manager app in your WordPress hosting cPanel.

首先,您需要访问WordPress网站并访问导致错误或警告的页面。 之后,您将需要使用WordPress托管 cPanel中的FTP客户端或文件管理器应用程序连接到您的网站。

Once connected, go to /wp-content/ folder and inside it your will find a file called debug.log.

连接后,转到/ wp-content /文件夹,然后在其中找到名为debug.log的文件。

Debug log

You can download, view, or edit this file. It will contain all WordPress errors, warnings, and notices that were logged.

您可以下载,查看或编辑此文件。 它将包含所有已记录的WordPress错误,警告和通知。

WordPress errors logged

That’s all we hope this article helped you learn how to set up WordPress error logs in WP-Config file. You may also want to see our ultimate list of most wanted WordPress tips, tricks, and hacks for beginners.

这就是我们希望本文帮助您了解如何在WP-Config文件中设置WordPress错误日志的全部。 您可能还想查看我们的初学者最想要的WordPress技巧,窍门和黑客的最终列表。

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

如果您喜欢这篇文章,请订阅我们的YouTube频道 WordPress视频教程。 您也可以在TwitterFacebook上找到我们。

翻译自: https://www.wpbeginner.com/wp-tutorials/how-to-set-up-wordpress-error-logs-in-wp-config/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值