Home >Backend Development >PHP Tutorial >php-error error log explanation

php-error error log explanation

小云云
小云云Original
2018-03-06 12:04:141836browse

For our PHP developers, when entering the production environment, we must turn off related debug, display_errors error prompts, etc. , how should we check PHP and other related errors in production? Recorded in the error log. error.log (or send directly to syslog)

The following is a brief description of how to configure and view the log.

1. Related configuration

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

1. error_reporting = E_ALL ;Every occurrence will be reported to PHP Error

2. display_errors = Off ; Do not display all error reports that meet the rules defined in the previous command

3. log_errors = On ; Turn on the error log

4. log_errors_max_len = 1024 ;Set the maximum length of each log entry

5. error_log = /var/php_errors.log ;Specify the location of the log file where the generated error report is written

PHP configuration file press After the above settings are completed, 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

  1. ##echo '' | 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

  1. vi /etc/php.ini


##3. View the log:

    tail -f -50 /var/php_errors.log
  1. In addition to general error output, PHP also allows Send customized messages in the system syslog. Although customized messages can also be sent to syslog through the error_log() function introduced earlier, PHP provides four dedicated functions for this feature that need to be used together. It will not be introduced here.

Related recommendations:

What is php custom error log? Detailed explanation of error log example code

php Detailed explanation of custom error log example

PHP program running error log information saving format issue

The above is the detailed content of php-error error log explanation. 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