The method to use the php error log is to first open the php configuration file; then modify the configuration [log_errors=On] to enable the error log; and finally restart the web server.
The operating environment of this article: windows10 system, php 7.3, thinkpad t480 computer.
If we want to use the error log, we first need to enable the error log. The specific method is as follows:
Edit the php.ini configuration file and make the following modifications:
error_reporting = E_ALL #将会向PHP报告发生的每个错误 display_errors = Off #不显示满足上条 指令所定义规则的所有错误报告,设置成off发生错误时,浏览器报500,不显示具体错误(具体错误不会输出到浏览器上,用户也就看不到。会写到第5步的错误文件中,非正式环境全设置成on更方便) log_errors = On #开启错误日志 log_errors_max_len = 1024 #设置每个日志项的最大长度 error_log =/usr/local/error.log #指定产生的 错误报告写入的日志文件位置
After the PHP configuration file is set as above, you need to restart the web server.
In this way, when executing any PHP script file, all error reports generated will not be displayed in the browser, but will be recorded in the error log /usr/local/error.log specified by you. . In addition, not only can all errors that meet the rules defined by error_reporting be recorded, but also the error_log() function in PHP can be used to send a user-defined error message and be written to the error_log.
Free learning video sharing:Introduction to programming
The above is the detailed content of How to use php error log. For more information, please follow other related articles on the PHP Chinese website!