PHP error Log notes

Source: Internet
Author: User
Tags php error php error log phpinfo syslog

I. Related configurations

The configuration directives in php.ini need to be modified as follows:

    1. error_reporting = E_all; Every 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; open 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 general error output, PHP also allows custom messages to be sent to syslog in the system. 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.
And share the time I've done. Cylindrical formwork industry Platform: http://zhimo.yuanzhumuban.cc/

PHP error Log notes

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.