Home  >  Article  >  Backend Development  >  PHP gets server error log

PHP gets server error log

尚
Original
2019-10-29 13:57:112798browse

PHP gets server error log

Configuration and viewing logs

1. Related configuration

You need to modify the configuration instructions in php.ini as follows:

1. error_reporting = E_ALL ; Every error that occurs will be reported to PHP

2. display_errors = Off ; All error reports that meet the rules defined in the previous directive will not be displayed

3. log_errors = On                                                                                                                                    Enter the log file location

After the PHP 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 the error_log() function in PHP can be used to send a user-defined error message.

2. Check the storage address

1. Check the error log storage address through php.ini

echo &#39;<?php phpinfo(); ?>&#39; | php 2>&1 |grep -i error_log

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

2. View the log storage location

vi /etc/php.ini

3. View the log:

tail -f -50 /var/php_errors.log

Recommended:

php server

The above is the detailed content of PHP gets server 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