开发者

Is it possible to log the IP address in php error_log?

I have been working with PHP for years and have never really thought about this until now. Obviously there are custom formats for display apache logs, but is there anything that can be done with php's error_log by php.ini?开发者_StackOverflow社区

I'd like to log the IP address of the originating error without having to modify every function on my website and include error_log($_REQUEST['REMOTE_ADDR'].' error etc');

Has anyone seen anything like this?


Apache should log this for you.

Here is an example from the error log for one of my php sites:

[Thu Mar 03 06:32:29 2011] [error] [client 188.226.15.54] PHP Notice: Undefined variable: profileRow in /public/html/mysite/profile.php on line 22

In my httpd.conf file, I have the following defined for the site

ErrorLog /var/log/apache2/mysite.com.error.log

Assuming you have the correct error level set for php, you should see your errors here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜