Example of a PHP error_log error message written to a file

Source: Internet
Author: User

Development, basically will display_errors,error_reporting open, help improve development efficiency, on-line, basically will turn off the page error information, in the error information, put in the file.

One, the error_log configuration of PHP-FPM

1, modify PHP.ini

Display_errors = off//To OFF, there is no error message when the page is accessed

2, modify the PHP-FPM configuration file

;p Hp_flag[display_errors] = off
Php_admin_value[error_log] =/var/log/php-fpm/www-error.log
Php_admin_flag[log_errors] = On

Restart PHP-FPM, where you should note that PHP-FPM configuration replaces the configuration in php.ini, Display_errors can also be configured in PHP-FPM. This will not appear on the page error information, error information is recorded in the file.

Second, command line error_log configuration, modify PHP.ini

Display_errors = Off
Log_errors = On
Error_log =/var/log/cron/error.log

To execute a command, such as:

[Root@network www]# PHP test.php//test.php syntax error

command line, is not called PHP-FPM configuration, so we can only modify the content of php.ini, modify, do not restart PHP. When the command is executed, the error message is written to the Error.log file, which is appropriate for the crontab PHP script.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.