在Debian系統中,PHP日志記錄級別的設置取決于你使用的PHP處理程序(例如Apache或Nginx)以及PHP本身的配置。以下是針對不同情況的設置方法:
編輯Apache的配置文件/etc/apache2/httpd.conf
或/etc/apache2/apache2.conf
,找到以下行:
LogLevel alert rewrite:trace6
將LogLevel
的值更改為你想要的日志記錄級別??蛇x的日志級別有:alert
, crit
, debug
, emerg
, err
, info
, notice
, warning
。例如,如果你想要更詳細的日志記錄,可以將級別設置為debug
:
LogLevel debug
保存文件并重啟Apache服務以使更改生效:
sudo systemctl restart apache2
編輯Nginx的配置文件/etc/nginx/nginx.conf
,找到location ~ \.php$
部分,然后修改fastcgi_param
指令以設置PHP日志記錄級別。例如,將日志級別設置為debug
:
location ~ \.php$ {
...
fastcgi_param PHP_VALUE "error_log=/var/log/nginx/php-fpm-debug.log debug";
...
}
保存文件并重啟Nginx服務以使更改生效:
sudo systemctl restart nginx
編輯PHP的配置文件/etc/php/7.x/apache2/php.ini
(對于Apache)或/etc/php/7.x/fpm/php.ini
(對于PHP-FPM),找到以下行:
error_reporting = E_ALL
將error_reporting
的值更改為你想要的日志記錄級別??蛇x的日志級別有:E_ALL
, E_ERROR
, E_WARNING
, E_PARSE
, E_NOTICE
, E_CORE_ERROR
, E_CORE_WARNING
, E_COMPILE_ERROR
, E_COMPILE_WARNING
, E_USER_ERROR
, E_USER_WARNING
, E_USER_NOTICE
, E_STRICT
, E_RECOVERABLE_ERROR
, E_DEPRECATED
, E_USER_DEPRECATED
。例如,如果你想要記錄所有錯誤和警告,可以將級別設置為E_ALL
:
error_reporting = E_ALL
保存文件并重啟相應的服務以使更改生效。對于Apache:
sudo systemctl restart apache2
對于PHP-FPM:
sudo systemctl restart php7.x-fpm
注意:請將7.x
替換為你的PHP版本號。