Jump to content

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/151006-solved-error_reporting-ignoring-me/
Share on other sites

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.

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??

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?

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! :(

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.

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.

> 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.

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.