Home >Backend Development >PHP Tutorial >Teach you how to enable PHP's error_log log

Teach you how to enable PHP's error_log log

WBOY
WBOYOriginal
2016-07-25 08:59:161922browse
This article introduces how to enable error_log in PHP. Friends in need can refer to it.

In PHP programming, for some PHP pages that do not have obvious error prompts when accessed, you can use error_log to make further judgments. However, for various reasons, some servers do not enable PHP's error_log function.

You can open it for testing or other needs. The method is as follows.

Edit php.ini and set log_errors to on:

log_errors = On

Then, just restart apache.

If it is successfully opened, you can track the corresponding error message:

[Mon Sep 24 16:57:01 2012] [error] [client 218.5.80.210] PHP Warning: fsockopen() has been disabled for security reasons in /home/bccgi-bin/fsockopen.php on line 2

[Mon Sep 24 16:57:02 2012] [error] [client 218.5.80.210] PHP Warning: fsockopen() has been disabled for security reasons in /home/bccgi-bin/fsockopen.php on line 2

[Mon Sep 24 16:57:03 2012] [error] [client 218.5.80.210] PHP Warning: fsockopen() has been disabled for security reasons in /home/bccgi-bin/fsockopen.php on line 2

[Mon Sep 24 16:57:04 2012] [error] [client 218.5.80.210] PHP Warning: fsockopen() has been disabled for security reasons in /home/bccgi-bin/fsockopen.php on line

In addition, note that in the Windows environment, in addition to setting log_errors to on, you also need to define the path and file name of error_log:

error_log = d:/temp/error.log

(This directory needs to be granted modification permissions to the php identity user, otherwise the log file cannot be generated) IIS does not have the concept of error_log, so it needs to be defined separately.

Whether it is PHP programming or system-based operation and maintenance, log files are very important. Develop the habit of collecting and analyzing logs. Sometimes it will be of great help in solving problems.



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn