Home  >  Article  >  Backend Development  >  How to set up php error log

How to set up php error log

coldplay.xixi
coldplay.xixiOriginal
2020-08-03 11:09:583228browse

php error log setting method: 1. Error log, code is [log_errors =On]; 2. Display errors, code is [display_errors = Off]; 3. Log path, code is [error_log = " /usr/local/lnmp/php..】.

How to set up php error log

php error log setting method:

php.ini:

; 错误日志
log_errors = On
; 显示错误
display_errors = Off
; 日志路径
error_log = "/usr/local/lnmp/php/var/log/error_log"
; 错误等级
error_reporting = E_ALL&~E_NOTICE

php-fpm.conf:

[global]
; php-fpm pid文件
pid = /usr/local/php/var/run/php-fpm.pid
; php-fpm 错误日志路径
error_log = /usr/local/php/var/log/php-fpm.log
; php-fpm 记录错误日志等级
log_level = notice
[www]
; 记录错误到php-fpm的日志中
;catch_workers_output = yes
; 慢日志
slowlog = var/log/slow.log
; 关闭打印日志
php_flag[display_errors] = off
; 错误日志
php_admin_value[error_log] = /usr/local/php/var/log/www.log
; 记录错误
php_admin_flag[log_errors] = on
; 内存使用量
php_admin_value[memory_limit] = 32M

Note:

If the error log is not written to file, check whether the www user has write permission to the path of `php_admin_value[error_log]`

Others:

  • `php_flag` Modify `php.ini` The configuration switch form On or Off can be modified by `ini_set`

  • `php_value` Modify the configuration value form in `php.ini` can be modified by `ini_set`

  • `php_admin_flag` Modify the configuration switch form On or Off in `php.ini` and cannot be modified by `ini_set`

  • `php_admin_value` Modify `php.ini The configuration value form in ` cannot be modified by `ini_set`

Related learning recommendations: PHP programming from entry to proficiency

The above is the detailed content of How to set up 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