简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM