Home > Article > Backend Development > php-error error log explanation
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
##3. View the log:
Related recommendations:
What is php custom error log? Detailed explanation of error log example codephp Detailed explanation of custom error log examplePHP program running error log information saving format issueThe above is the detailed content of php-error error log explanation. For more information, please follow other related articles on the PHP Chinese website!