1

OK, I'm clearly missing something about how error logging is supposed to work. This is a D7 production site, so my goal is to get errors written into a log file, but not show up on the screen. I've added the following to the end of my site's settings.php file:

error_reporting(E_ALL); // just to get going; I'll scale this back later
ini_set('display_errors', 0); // don't display errors on the screen
ini_set('log_errors', 1); // log errors...
ini_set('error_log', 'syslog'); // ...in the syslog (I'm running this on Fedora 15, 
                                // so I think this should work (although I'd happy to
                                // have the logging happen somewhere else

My reading of all the docs makes me think that this should work, but when I put the following into a module file as a way of forcing some errors:

$x = 1 / 0;
$foo = $bar + $baz;

I still get the divide-by-zero warning and the undefined variable notices coming up on the screen via drupal_set_message, and comparable messages in watchdog. If I instead do error_reporting(0), I get nothing on the screen, and nothing in watchdog. In no case do I see any messages showing up anywhere in /var/log.

I'm clearly doing something wrong, no? Can anyone see what it is?

  • Consider accepting answers and upvoting decent answers for your previous posts. Your acceptance rate is quite low. – stefgosselin Apr 27 '12 at 6:01
  • I thought I'd been okay with that, but digging into a new culture is always a learning process. I'll keep in mind; thanks. – Jim Miller Apr 27 '12 at 19:55
  • Update: I had wanted to make this change at the site level rather than changing the settings in php.ini, hence my use of the calls in settings.php. Nevertheless, I tried making the changes directly in php.ini, and got the same results. The only way I've been able to affect what and where errors happen is through the controls in admin/config/development/logging -- if I set "error messages to display" to "none", I get entries in watchdog but not on the screen (but still not in any of the httpd logs), which I guess is good enough. Drupal seems to be playing some gains behind the scenes... – Jim Miller Apr 27 '12 at 19:59
  • That is nice. I still believe you would get more helpful answers in the future if you improved your acceptance rating. This (and a lot more) is all explained in the awesome faq page. – stefgosselin Apr 27 '12 at 23:07
2

Just to be sure that you are in the right path...

PHP.net says that:

Note:

Although display_errors may be set at runtime (with ini_set()), it won't have any affect if the script has fatal errors. This is because the desired runtime action does not get executed.

Also check http://www.php.net/manual/en/errorfunc.configuration.php#ini.log-errors and http://www.php.net/manual/en/errorfunc.configuration.php#ini.error-log

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.