2

I want to log all PHP errors into a log-file, but I don't want to display them to the user.

I use the following configuration in php.ini

track_errors=On
error_reporting = E_ALL
log_errors=On
display_errors = Off
error_log = php-error.log
date.timezone = Europe/Berlin

The problem I face right now: I use an Ionic app. This request some php files on my server. When this php file contains some warnings, they are getting transferred too, and the Ionic app stops working, as it just expects a jsonp response with a callback, and doesn't allow any echoed statements or similar things. So I use error_reporting(0); at the beginning of every file, but this shuts of errors completely again.

How can I completely turn off the errors from being transferred/displayed, and just write them to a file?

John Brunner
  • 2,842
  • 11
  • 44
  • 85
  • display_errors = Off should do the trick, are you sure that you're using the correct php.ini file? You'll need to restart your server after php.ini changes for them to take effect. – H2ONOCK Oct 15 '16 at 10:06
  • I'm using a managed server. I'm not sure if I can restart this machine. But if I can trust `phpinfo();`, then `display_errors` should be off. – John Brunner Oct 15 '16 at 10:16
  • What happens if you put ini_set('display_errors', '0'); at the top of your php script? – H2ONOCK Oct 15 '16 at 10:48

1 Answers1

0

Another solution is to implement your own error handler script/class which you can include in your project or in every script of your app. This will allow you to take the advantage of logging whatever error you want.

krasipenkov
  • 2,031
  • 1
  • 11
  • 13