PHP online error log control (error_reporting and display_errors)

Source: Internet
Author: User
Tags ini php error php online

We know that the production environment of the product is definitely not incorrectly displayed, so:
Change display_errors = Off to display_errors = On in php. ini.
Or ini_set ('display _ errors ', 0 );

Secondly, we know that the php error level is controlled by error_reporting [error_reporting detailed tutorial], but many people disable the error message in the production environment.
Error_reporting (0 );

In fact, this practice is not scientific in my opinion. It is like this in the codeigniter framework.

The code is as follows: Copy code

If (defined ('enable '))
Case 'development ':
Error_reporting (E_ALL );
Case 'testing ':
Case 'production ':
Error_reporting (0 );
Exit ('The application environment is not set correctly .');

Online error information must be recorded. error_reporting (0) will not record all error information. It should be: error_reporting = E_ALL &~ E_NOTICE: as long as display_errors = Off, the error message will not be displayed on the page, because display_errors has a higher priority.

If php. log_errors = On in ini. According to the official statement, the error_log file must be specified. If the specified file is not specified or the specified file does not have the write permission, the file will still be output to the normal output channel, in this case, the specified Off of display_errors is invalid, and the error message is printed. Set log_errors to Off.

In summary, the following error logs can be recorded for unrealistic error information in the production environment:


The code is as follows: Copy code
<? Php
* Records production environment error logs
* @ Link
Error_reporting (E_ALL );
Ini_set ('display _ errors ', 0 );
Ini_set ('log _ errors ', 1 );
Ini_set ('error _ log', 'E: \ '.date('y-m-d'{.' ');
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.