Home >Backend Development >PHP Problem >How to read the request log in php server
How to view the request log in php on the server
1. View the request log through Nginx
cd /usr/local/nginx/conf/vhost vi xxx.xxx.conf
Set or view the location where the log is savederror_log
server { access_log /data/log/www; listen 80; server_name abc.com www.abc.com; location / { root /data/www/www; index index.html index.htm; } error_log logs/error_www.abc.com.log error; (这是查看错误日志文件的位置) }
View the log
cat logs/error_www.abc.com.log
2. Through Apache View the request log
$cd /var/log/apache2 $ls access.log error.log ...
View the successful request log
cat /var/log/apache2/access.log
View the failed request log
cat /var/log/apache2/error.log
3. Turn on the php log function and check
a) You need to modify the configuration instructions in php.ini as follows:
error_reporting = E_ALL ;将会向PHP报告发生的每个错误 display_errors = Off ;不显示满足上条 指令所定义规则的所有错误报告 log_errors = On ;开启错误日志 log_errors_max_len = 1024 ;设置每个日志项的最大长度 error_log = /var/php_errors.log ;指定产生的 错误报告写入的日志文件位置
PHP After the configuration file is set as above, restart the web server. In this way, when executing any PHP script file, all error reports generated will not be displayed in the browser, but will be recorded in the error log /usr/local/error.log specified by you. In addition, not only can all errors that meet the rules defined by error_reporting be recorded, but also a user-defined error message can be sent using the error_log() function in PHP.
2. Check the storage address
b) Check the error log storage address through php.ini
echo '<?php phpinfo(); ?>' | php 2>&1 |grep -i error_log
Or output phpinfo(); in a php file to check the error log Storage location
c) Check the log storage location
vi /etc/php.ini
For more PHP related knowledge, please visit PHP Chinese website!
The above is the detailed content of How to read the request log in php server. For more information, please follow other related articles on the PHP Chinese website!