How to read the request log in php server

angryTom
Release: 2023-02-27 22:00:02
Original
6974 people have browsed it

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
Copy after login

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;     (这是查看错误日志文件的位置)
}
Copy after login

View the log

cat logs/error_www.abc.com.log
Copy after login

2. Through Apache View the request log

$cd /var/log/apache2
$ls
access.log error.log ...
Copy after login

View the successful request log

cat /var/log/apache2/access.log

View the failed request log

cat /var/log/apache2/error.log
Copy after login

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            ;指定产生的 错误报告写入的日志文件位置
Copy after login

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 &#39;<?php phpinfo(); ?>&#39; | php 2>&1 |grep -i error_log
Copy after login

Or output phpinfo(); in a php file to check the error log Storage location

c) Check the log storage location

vi /etc/php.ini
Copy after login

How to read the request log in php server

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!