Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to output php error log

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report