Get the App
SLTechnology News&Howtos  ›  Development  › 

How to output php error log

Shulou Source: shulou.com Published: 2022-06-03 10:52:50 09月19日 Update

This article is about how to output php error logs. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Output php error log: 1, modify the catch_workers_output and error_log configuration in php-fpm.conf; 2, modify php.ini configuration file; 3, restart php-fpm.

This article operating environment: 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 visited page, not 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 errorlog of php can not be seen in the errors log of php-fpm.

The reason for this is that php-fpm 's 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 can't see the error log of php in nginx's errorlog or php-fpm 's errorlog.

But in this way, it will be very painful for us to debug, so how can we solve this problem? Let's take a look at it.

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

Catch_workers_output = yeserror_log = log/error_log

2. Modify the configuration in php.ini. If not, add it.

Log_errors = Onerror_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 that the error log is in "/ usr/local/lnmp/php/var/log/error_log".

Thank you for reading! This is the end of the article on "how to output php error log". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Tags: Error log output configuration information content file more see article process good practical painful in that case reason only situation article method Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Shulou Technology macOS Microsoft Huawei