Preface: For us to do PHP development personnel, on the production environment, must be related to debug,display_errors error tips, such as turn off. Who can not avoid a mistake. This can prevent non-fatal error, resulting in project path, database and other information leakage. Q: So the question is, how are we going to make some related mistakes in how to view PHP? A: Record in the error log. Error.log (or sent directly to Syslog)
Below is a brief description of how to configure and view the log.
The configuration instructions in the php.ini need to be modified as follows: 1. error_reporting = e_all ; will report every error that occurred to PHP 2. display_ errors = off ; do not display all error reports that meet the rules defined by the previous Directive 3. log_errors = on Open Error Log 4. log_errors_max_len = 1024 ; set maximum length of each log entry 5. error_log = /var/ php_errors.log ; Specifies the resulting Error report write log file location PHP configuration file as set above, and restart the Web server. This way, when you execute any script file in PHP, all the error reports that are generated are not displayed in the browser, but are recorded in the error log/usr/local/error.log that you specified. In addition, noYou can only record all errors that satisfy the rules defined by error_reporting, and you can also use the Error_log () function in PHP to send out a user-defined error message.
Two. View store address 1. View error log address by php.ini
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 log:
Tail-f -50/var/php_errors.log
In addition to the normal error output, PHP allows you to send custom messages to System syslog. Although the Error_log () function described earlier can be used to send custom messages to Syslog, this feature is provided in PHP with 4 specialized functions that you need to work with. Here is not the introduction.
Reference address: PHP error log: http://blog.csdn.net/breeze_life/article/details/9368575
System log: Record system related information: http://blog.csdn.net/ty_hf/article/details/55511624 Apache access logs and error logs: http://blog.csdn.net/ty_hf/ article/details/55504719 nginx access log and error log: http://blog.csdn.net/ty_hf/article/details/55518070 php-fpm slow Log : Detect slow PHP script: http://blog.csdn.net/ty_hf/article/details/55504172 PHP error log: Detects PHP run or user logs error log: http:// blog.csdn.net/ty_hf/article/details/55505262 MySQL slow log: Record the performance sql:http://blog.csdn.net/ty_hf/article/in the MySQL server details/55504172
This article address: http://blog.csdn.net/ty_hf/article/details/55505262