Drupal catches PHP warnings and notices to log them via dblog or syslog. As a result, there are two places to monitor for PHP errors (with the watchdog UI not well suited to cater for any large number of notices).

Is it possible to prevent this behavior and have ALL php errors be logged to the error_log defined in the php config?

  • If the syslog module (in core) is working as expected, you should be able to disable the dblog module (also core). That will remove the watchdog UI page as well. – Neograph734 Dec 16 '13 at 21:55
  • Thank you, but my question is neither aimed at disabling watchdog completely nor using syslog. – cjoy Dec 17 '13 at 10:43

For that, you will need to implement the hook_watchdog to make calls to the error_log() function.

You could as example one of the places where is implemented, that is the syslog_watchdog. Instead of use the openlog() and syslog() function, you will use the error_log().

  • While this does not prevent PHP warnings and notices from being passed to dblog/watchdog, it makes possible the passing of php related entries to the default error_log. Thanks! – cjoy Dec 17 '13 at 13:32

Rudimentary code example for the solution provided by @gerzenstl

 * Implements hook_watchdog()
function MYMODULE_watchdog(array $log_entry) {

  if($log_entry['type'] == 'php') {

    $output = format_string($log_entry['message'], $log_entry['variables']);
    $output =  strip_tags($output);



Got here when googling for the same. I want watchdogs go to webserver logging, since I use Docker. After checking @gerzenstl links, I tried again looking if someone already coded it and finally found a module: https://www.drupal.org/project/logging_alerts

The 'errorlog' submodule does exactly this. Overall, all the modules are very complete and provide other useful goodies. Solved this without coding!

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.