dave_biscuits Posted March 25, 2009 Share Posted March 25, 2009 I currently have PHP logging all errors to /var/log/httpd-error.log (FreeBSD 7.0) by default and I'm trying to get it to only log fatal errors (as warnings keep filling up the log file a lot). Now, I've currently got the following PHP variables set (and have confirmed the .ini path just in case): error_reporting = E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR display_errors = Off log_errors = On I've tried numerous syntax to try and get it to stop logging warnings but it just seems to keep logging every everything - what am I missing?? does log_errors just log everything no matter what? Quote Link to comment https://forums.phpfreaks.com/topic/151006-solved-error_reporting-ignoring-me/ Share on other sites More sharing options...
PFMaBiSmAd Posted March 25, 2009 Share Posted March 25, 2009 If you are changing the master php.ini, you must stop and start the web server to get any change made to take effect. Well written code does not normally generate warning or notice errors when it executes. You should only get warnings and notices for unexpected conditions and you should always have error_reporting set to E_ALL so that you will have a record of unexpected and uncaught conditions that occur, such as when a legitimate visitor feeds your code some valid but unexpected data or when a hacker feeds your code unexpected data in an attempt to break in. Also, every line of code that generates a warning or notice error takes 10-20 times longer to execute, taking up processing time and using server resources. Quote Link to comment https://forums.phpfreaks.com/topic/151006-solved-error_reporting-ignoring-me/#findComment-793329 Share on other sites More sharing options...
dave_biscuits Posted March 25, 2009 Author Share Posted March 25, 2009 Yep, rebooted numerous times and no change. Server is for an internal web app, so no real danger of hackers - plus the coding involved is enormous (~6 years worth) so making it squeaky clean isnt really an option - four billion warnings like running an empty variable through a foreach function doesnt really worry me. Either way, I still need to figure out why php wants to log everything when im trying to ask it to only log errors only ... perhaps it only affects 'display_errors' and not log_errors?? Quote Link to comment https://forums.phpfreaks.com/topic/151006-solved-error_reporting-ignoring-me/#findComment-793331 Share on other sites More sharing options...
PFMaBiSmAd Posted March 25, 2009 Share Posted March 25, 2009 Then the php.ini that you are changing is probably not the one the php is using or you have something like a .htaccess file or a local php.ini that is overriding the setting. What does a phpinfo() statement show for Loaded Configuration File and what does it show for the error_reporting setting? Quote Link to comment https://forums.phpfreaks.com/topic/151006-solved-error_reporting-ignoring-me/#findComment-793337 Share on other sites More sharing options...
dave_biscuits Posted March 25, 2009 Author Share Posted March 25, 2009 Still no joy. I dont think php.ini is being overridden, I've changed php.ini to record to /var/log/php.log because I thought apache might be stuffing it around ... anyway, phpinfo() reads: error_log /var/log/php.log /var/log/php.log log_errors On On error_reporting 64 64 (error_reporting = E_COMPILE_ERROR for this particular test run ...) and yet php.log still stamps: [25-Mar-2009 15:00:27] PHP Warning: Invalid argument supplied for foreach() in /usr/local/www/data-dist/ ...... argh! Quote Link to comment https://forums.phpfreaks.com/topic/151006-solved-error_reporting-ignoring-me/#findComment-793370 Share on other sites More sharing options...
Mark Baker Posted March 25, 2009 Share Posted March 25, 2009 I currently have PHP logging all errors to /var/log/httpd-error.log (FreeBSD 7.0) by default and I'm trying to get it to only log fatal errors (as warnings keep filling up the log file a lot). Of course, it's also a worthwhile exercise to fix all those niggardly little bugs that generate all these warnings. At the very least, they're slowing down the script execution; and may actually be causing more severe errors that you haven't noticed yet. Quote Link to comment https://forums.phpfreaks.com/topic/151006-solved-error_reporting-ignoring-me/#findComment-793466 Share on other sites More sharing options...
PFMaBiSmAd Posted March 25, 2009 Share Posted March 25, 2009 I dont think php.ini is being overridden In programming in is not enough to think something is happening or not, you must know that something is or is not being done by thoroughly checking, because computers only do exactly what their programming tells them. Your scripts are probably setting the error reporting level. Have you checked in them to see? For the example of a foreach() statement that was not passed an array. That means the code did not receive the data it expected. It probably also means that there are related errors further down on that page because the foreach() loop did not produce the results that it was expected to have produced, causing unexpected operation of the code. There is no excuse for php code that generates warnings and notice errors during its normal execution. Hiding those errors won't fix code that is not functioning correctly and would in fact prevent debugging of simple things like a form field name that contains a typo that would cause data to be missing in a variable. Quote Link to comment https://forums.phpfreaks.com/topic/151006-solved-error_reporting-ignoring-me/#findComment-793639 Share on other sites More sharing options...
dave_biscuits Posted March 26, 2009 Author Share Posted March 26, 2009 > Your scripts are probably setting the error reporting level. Have you checked in them to see? You were correct - just as I was about to give up I found this in the database connection script that 99% of all the pages call upon starting: error_reporting(E_ERROR | E_WARNING | E_PARSE); Many thanks, cheers. Quote Link to comment https://forums.phpfreaks.com/topic/151006-solved-error_reporting-ignoring-me/#findComment-794229 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.