Update:
The comments on this @mpc answer in the browser display errors when display_errors enabled, but they are not displayed in the log. I assumed that the errors did not appear at all.
Are E_NOTICE errors the only ones that do not appear in the log, or are all types of errors affected? If all types of errors, then the first thing I would like to check is to enable or disable error logging. Try setting ini_set('log_errors', 'On'); at the top of your script. If this does not work, try setting up the log file so that you are sure that your server can write by calling ini_set('error_log', 'your_file_path'); . If none of them work, I think something is seriously out of line with your PHP installation. If any of these fixes work, you can put them in the actual php.ini if you have access.
Original answer:
Based on the error_reporting level in your question, your PHP installation should already be configured to report E_NOTICE errors. If he does not register these errors, something is wrong. I would suggest turning on display_errors to see if any E_NOTICE errors are E_NOTICE . If you canβt modify the php.ini , try running ini_set('display_errors', 'On'); at the top of your script. Obviously, these errors will only be displayed and / or recorded if you run one of them, so you should double-check that you are actually doing this.
One caveat is that the error level E_DEPRECATED was only introduced with PHP 5.3. When I just tested the installation of E_DEPRECATED when installing PHP 5.2, PHP responded with errors and set the error_reporting level to 0 , which means that it does not report errors at all. Although it makes no sense to use this parameter for the pre-5.3 php.ini , I consider it important to at least increase the likelihood of using E_DEPRECATED on a server that does not support it. If you are not sure about your version, you can run phpinfo() and display a page with a lot of information, including the version number for your installation.
Despite the foregoing, if I misunderstood your question, and you are only talking about creating your own custom logging, then you need to create a function to run when an error occurs and assign it as an error handler using set_error_handler() .
It is important to note that when using set_error_handler() you completely set_error_handler() default PHP error handler. This means that your error_handler level becomes meaningless. All errors, regardless of their severity, will be passed to the error handler function you created. The first parameter passed to this PHP function will be the error number, which is the numeric value of the constant E_xxx the error found. You will need to write your own code to catch only the errors you need.
For example, to catch only E_NOTICE errors, your function would look like this:
function my_error_handler($errno, $errstr, $errfile, $errline) { if ($errno == E_NOTICE) {