I'm trying to write a custom message to my log (viewable at /admin/reports/dblog) using the watchdog function.

function create_vector_user_mail($key, &$message, $params) {
   watchdog("VECTOR", "inside user mail", array(), WATCHDOG_INFO);
   /* other stuff */

I have the core database logging module enabled, and the log is set to display all messages. But this message isn't getting saved to the log. I've used a standard php error_log just to make sure the create_vector_user_mail function is running, and it is. I copied the watchdog line from another contrib module that does print its messages correctly. What am I doing wrong?

  • Are you sure your hook implementation is being called at all? – cilefen Oct 13 '15 at 19:08
  • @cilefen - as I said, I used an error_log call to be sure it was being called, and it is. I want to use watchdogs because I don't have direct access to the php error logs on our qa and staging systems. – EmmyS Oct 13 '15 at 19:16
  • I guess it would help if I read the entire question! I use watchdog() all the time and that usage looks correct to me. You didn't mention if ordinary system events are making to the log. Are they? – cilefen Oct 14 '15 at 19:29
  • The code is correct. You should use your logging to capture the array output of module_implements('watchdog'); if dblog isn't in the array, dblog_watchdog isn't be called to insert a log into the DB. – Shawn Conn Oct 14 '15 at 20:36

Your Answer

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

Browse other questions tagged or ask your own question.