How can I filter sensitive data being recorded in calls to Watchdog I have sensitive data that is sent to a Drupal instance and I don't want it to be logged. I can filter out sensitive values with simple string replacements for my own calls to watchdog(), but for PHP errors and other modules making watchdog() calls, the data may be logged and this needs to be filtered too.
Assuming you're dealing with the dblog module, this is a workable solution:


Disable the dblog module
Copy dblog_watchdog into your own module's hook_watchdog implementation
Wrap each of the appropriate database field entries with your function to sanitise the string, e.g.

Database::getConnection('default', 'default')-&gt;insert('watchdog')
  -&gt;fields(array(
    'uid' =&gt; $log_entry['uid'],
    'type' =&gt; mymodule_sanitise(drupal_substr($log_entry['type'], 0, 64)),
...



If you have other watchdog modules in use, you'll need a copy/edited hook_watchdog version for each of them too.