Home  >  Article  >  Backend Development  >  How to output php error log

How to output php error log

王林
王林Original
2021-09-22 15:19:123170browse

Method to output php error log: 1. Modify the catch_workers_output and error_log configuration in php-fpm.conf; 2. Modify the php.ini configuration file; 3. Restart php-fpm.

How to output php error log

The operating environment of this article: windows10 system, php 7&&nginx 1.14, thinkpad t480 computer.

We all know that nginx is a web server, so the access log of nginx only records the accessed pages, and does not have the error log information of php. nginx sends the request for php to the php-fpm fastcgi process for processing. The default php-fpm will only output the error message of php-fpm, and the error log of php cannot be seen in the errors log of php-fpm.

The reason for this situation is that the php-fpm configuration file php-fpm.conf turns off the error output of the worker process by default and redirects them directly to /dev/null, so we Neither the error log of nginx nor the error log of php-fpm can see the error log of php.

But in this case, it will be very painful for us to debug, so how should we solve this problem? Let’s take a look below!

1. Modify the configuration in php-fpm.conf and add

catch_workers_output = yes
error_log = log/error_log

2. Modify the configuration in php.ini and add

log_errors = On
error_log = "/usr/local/lnmp/php/var/log/error_log"
error_reporting=E_ALL&~E_NOTICE

3. Restart php-fpm

When PHP executes errors, you can see the error log in "/usr/local/lnmp/php/var/log/error_log".

Recommended learning: php training

The above is the detailed content of How to output php error log. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn