亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

PHP error handling error log

In some companies, there is a special log collection system. The log collection system will silently help you collect errors, warnings, and prompts behind the scenes.

There are also some companies that do not have a dedicated log collection system and collect the running logs from the server through files.

Among them: PHP errors and warnings must be received.

Then the question comes - if users are not allowed to see it, and the error reporting level is set, how to collect errors into the log system?

Here are the relevant configuration items that need to be used in php.ini. These two configuration items are:

ParameterConfiguration itemDescription
log_errorson/offWhether to enable logging
log_errors_max_lenInteger type, default 1024 Maximum record length of single-line errors
error_logsyslog or specified pathWhere the error log is recorded

Note:

1. The log_errors and log_errors_max_len in the table are very easy to understand.

2. The error_log specifies the path on which the error will be stored. The syslog in the configuration items may be a bit difficult to understand. syslog refers to system recording. Windows system is in the log collector of the computer. Linux defaults to: /etc/syslog.conf

[Extension] Learn about the knowledge points. If the Linux system is started or log collection is modified. May be stored on third-party dedicated log collection servers.

In addition, PHP also specially prepared a custom error log function for us:

bool error_log (string $error message[, int $error message type = 0 [, string $storage Target]] )

This function can send error information to the error log of the web server, or to a file.

Commonly used error message types:

Error message typesDescription
0Send to the default error_log specified location
1Send to the specified email location
3Send to the specified file location


Example:

<?php

//無法連接到數(shù)據(jù)庫(kù)服務(wù)器,直接記錄到php.ini 中的error_log指定位置
error_log("無法連接到數(shù)據(jù)庫(kù)服務(wù)器服務(wù)器");

//可以發(fā)送郵件,但是php.ini必須配置過郵件系統(tǒng)
error_log('可以用郵件報(bào)告錯(cuò)誤,讓運(yùn)維人員半夜起床干活',1 ,'pig@php.cn');

//記錄在指定的位置
error_log("我是一個(gè)錯(cuò)誤喲", 3, "d:/test/my-errors.log");

?>

Note:## Sending emails in #error_log may be unfamiliar to beginners, so you don’t need to master some knowledge.


Continuing Learning
||
<?php //無法連接到數(shù)據(jù)庫(kù)服務(wù)器,直接記錄到php.ini 中的error_log指定位置 error_log("無法連接到數(shù)據(jù)庫(kù)服務(wù)器服務(wù)器"); //可以發(fā)送郵件,但是php.ini必須配置過郵件系統(tǒng) error_log('可以用郵件報(bào)告錯(cuò)誤,讓運(yùn)維人員半夜起床干活',1 ,'liwenkai@phpxy.com'); //記錄在指定的位置 error_log("我是一個(gè)錯(cuò)誤喲", 3, "d:/test/my-errors.log"); ?>
submitReset Code