PHP errors

Can anyone help shed light on how I can get my developers to be able to log and view PHP errors that would happen on a specific site? I have a php.ini file, and it looks like error_log = error_log is in there, as well as showing all errors, but I’m not sure what else to do to get them to be able to see any php errors. The site is on a linux server, but would be nice to know how to do it on linux or windows.

Thanks,
-Ben

as far as I know, on linux the php.ini file will be ignored, that only works on windows., you need to set the changes in htaccess or use ini_set in the php page itself.

They are using that as well, but it doesn’t seem to mail or log the error like we have it set up to do. Any other ideas?

I’ve not tested this, but steps should generally be:

  1. Error log file log location should be writable by web server user. So you may create a folder outside and chmod it to 777.
  2. Set error_log path (in .htaccess file) to any file name inside folder created above.
  3. Set error reporting (in .htaccess file) as per your needs.

I haven’t done this in an .htaccess, only a php.ini. But, you’ll need these settings (copied from my php.ini file…you’ll need to translate to the htaccess syntax):

error_reporting = E_ALL & ~E_NOTICE [I](or whatever you want to see)[/I] display_errors = Off log_errors = On error_log = /hshome/[I]account[/I]/[I]path[/I]/[I]file.log[/I]

Make sure that file.log is writable (777).

I think the syntax is something like:

php_flag error_reporting E_ALL & ~E_NOTICE
etc…

Tim

Ok, I finally stumbled upon the way to get this to work:

ini_set('display_errors', 1); ini_set('log_errors', 1); ini_set('error_log', dirname(__FILE__) . '/error_log.txt'); error_reporting(E_ALL);

Then you create that error_log.txt and change permissions to 777 on it.

Wanted to post here so if anyone else runs into this issue and needs a way around the php.ini or .htaccess file.

-Ben

Thank you, Tim and Ben, for posting your working configuration. It sure will help many.