PHP Logging Method

Source: Internet
Author: User
PHP has always been regarded as a language that cannot be used on the table, mainly because it relies heavily on various functions. But in fact, PHP is also the most widely used language in the website, which is related to its simplicity and convenience. Compared with other Website Languages, PHP does not have its own server and relies on servers such as Apache. If you use Tomcat, you will obviously feel that PHP is missing.

PHP has always been regarded as a language that cannot be used on the table, mainly because it relies heavily on various functions. But in fact, PHP is also the most widely used language in the website, which is related to its simplicity and convenience. Compared with other Website Languages, PHP does not have its own server and relies on servers such as Apache. If you use Tomcat, you will obviously feel that PHP is missing.

PHP has always been regarded as a language that cannot be used on the table, mainly because it relies heavily on various functions. But in fact, PHP is also the most widely used language in the website, which is related to its simplicity and convenience. Compared with other Website Languages, PHP does not have its own server and relies on servers such as Apache. If you use Tomcat, you will obviously feel that PHP has a background console missing, in the Tomcat console, you can see the log information output by the program. PHP lacks this capability. When you need to view logs in the background in real time when developing a PHP program, it is difficult to achieve your wish. A work und is to import logs to a file. PHP provideserror_log()To quickly output logs to a specified file.

The interface of this function is described as follows:

bool error_log ( string $message [, int $message_type = 0 [, string $destination [, string $extra_headers ]]] )

The first parameter is the log to be output, and the second parameter is the output mode. There are four methods, respectively:

Error_log ()Log Type
0 messageSystem log sent to PHP, use
The log mechanism or file of the operating system depends on
What is set by the error_log command.
This is a default option.
1 messageSend to Parameterdestination
The email address.
Fourth Parameterextra_headersIt is used only in this type.
2 It is no longer an option.
3 messageSentdestination.
CharactermessageIt is not treated as a new row by default.
4 messageIt is directly sent to the log processing program of SAPI.

The most common one is output to a log file, which is 3.

The following is an example of usage:

 

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.