Skip to content
Advertisement

Is it possible to change PHP error log output?

I have configured the error_log directive in my php.ini file, like this:

JavaScript

And then I configured the error_reporting directive like this:

JavaScript

When I check the error_log file, I see normal PHP warning/error text lines:

JavaScript

Is there is a way to change output format? I mean, if I can print, for example, the IP address and the subdomain that cause the warning.

I was looking for it on Stack Overflow, in Google Search, and I don’t find clear information or examples.

Advertisement

Answer

So agreeing to and finalizing all the comments given above, the best approach is to set_error_handler.

I wrote a class for you. I also like to set_exception_handler to have a unified experience and save all the errors in Error::$throwables to display them on shutdown instead of the View (handled by View class not provided here).

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement