We recently upgraded a server from PHP4 to PHP5.4
There is an application running that is logging a lot of errors in the log file. Most of them are deprecated errors, or some minor things due to the change in PHP versions.
I don’t have time to fix all the problems right now, but the error_log file has ballooned to 10G in just a few days.
In php.ini I set
log_errors = Off
What else can I do ?
It depends on which errors you want to report, if any. If you don’t want any errors to be reported (bad idea, I think), go with:
At the top of the script.
If you only want to turn off the deprecated errors, you would need to use some bitwise operators using the predefined error constants. I believe the following would work and fit what you have in mind:
This would still leave in fatal errors and catchable errors, (2 of those 3 will halt the script so they are good to catch), but leave out the “your script is old” type errors.
It is also possible to send the less desired errors to another error log, so that they can be dealt with later, but not clog the main error log. Ask if interested.
Quick Edit:
Because
E_STRICTis not included inE_ALL, the above would turn onE_STRICT(which is only confusing when we assume that ALL means, well, all of them (all bits flipped). So this would produce the desired result of the those three errors being turned off:or, to eat my words on the comment on zuul’s answer, this would also work (though the logic hurts my head):
Also, since you mentioned Apache specifically, you should know that you can’t use the predefined error constants outside of a PHP script, you have to use the actual bitmask values. In this case, you would add the following to the config or htaccess file:
I’m not finding anywhere in the documentation where bitwise operations are supported in this scenario, so if you wanted to tweak the error_reporting level, you could simply create a php script with the following:
Which will output the decimal form of that bitmask to use (obviously changing the constants to match what you want to turn off).