For us to do PHP development personnel, on the production environment, must be related debug,display_errors error prompts and so on. , we are producing how to view PHP and other related errors? Logged in the error log. Error.log (or send directly to syslog)
Below is a brief description of how to configure and view the logs.
I. Related configurations
The configuration directives in php.ini need to be modified as follows:
1. error_reporting = E_all; Each error that occurs will be reported to PHP
2. display_errors = OFF; do not display all error reports that meet the rules defined by the previous instruction
3. log_errors = on; turn On error log
4. Log_errors_max_len = 1024; Sets the maximum length for each log entry
5. Error_log =/var/php_errors.log; Specifies the log file location where the resulting error report is written
The PHP configuration file is set up as above and restarts the Web server. Thus, 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 that you specified. In addition, you can not only record all errors that meet the rules defined by error_reporting,
You can also use the Error_log () function in PHP to send a user-defined error message.
Two. View storage address
1. Use PHP.ini to view the error log storage address
Echo ' <?php phpinfo ();?> ' | PHP 2>&1 |grep-i error_log
or output phpinfo () in a php file; see where the error log is stored
2. View Log storage location
Vi/etc/php.ini
3. View the log:
Tail-f -50/var/php_errors.log
In addition to the generic error output, PHP allows custom messages to be sent to system syslog. Although a custom message can be sent to the syslog using the Error_log () function described previously, there are 4 specialized functions that need to be used in PHP for this feature. There is no introduction here.