Php-error Error Log explanation

Source: Internet
Author: User
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

    1. 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

    1. Vi/etc/php.ini


3. View the log:

    1. 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.