For some reason I couldn't use devel to debug output object arrays. Is there a way to output the array data to watchdog error reporting? This would also solve the issue of having to install or enable another module.

3 Answers 3


You can use watchdog but the message part should be translatable, so any variables should use placeholders defined in the variables array. Check out format_string to see how these should work.

  'Here is the printed variable: <pre>@placeholder_name</pre>',
  array('@placeholder_name' => print_r( $my_variable, TRUE)),

Also, convention dictates that the first parameter, $type, should be the module name calling watchdog.


You can do the following to output array data to be viewed in watchdog:

// Directly use values.
watchdog("log_name", '<pre>' . print_r( $my_object, true) . '</pre>');

Then goto /admin/reports and look for "log_name".

  • 1
    Watchdog runs through the translation function, so you need to use variables. See my answer. Commented Jul 25, 2017 at 10:52

If you don't mind enabling another module, though, I wrote Object Log for just this kind of thing:


It's lightweight, easier to use in code, more user-friendly to view, and doesn't get pushed down the log as other log events are recorded.

  • rather not install another module. not exactly practical if I only needed to do it once to see the array output. thanks tho. Commented Jan 26, 2016 at 0:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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