I am developing a custom module, and I'd like to log my own log entries with their own type, so that they can be accessed and filtered at admin/reports/dblog.

But I can't find the appropiate function or script. Any suggestions?

2 Answers 2


watchdog() is what you are looking for. See the description of its parameters, in particular these:

$type: The category to which this message belongs. Can be any string, but the general practice is to use the name of the module calling watchdog(). The $type parameter is limited to 16 characters; anything longer is truncated.

$severity: The severity of the message; one of the following values as defined in RFC 3164:

  • WATCHDOG_EMERGENCY: Emergency, system is unusable.
  • WATCHDOG_ALERT: Alert, action must be taken immediately.
  • WATCHDOG_CRITICAL: Critical conditions.
  • WATCHDOG_ERROR: Error conditions.
  • WATCHDOG_WARNING: Warning conditions.
  • WATCHDOG_NOTICE: (default) Normal but significant conditions.
  • WATCHDOG_INFO: Informational messages.
  • WATCHDOG_DEBUG: Debug-level messages.

$link: A link to associate with the message.


A possibly alternative for logging custom log entries, is to use the Rules module:

  • The Drupal 6 version of Rules has the ability to create a watchdog entry.
  • This functionality is not (yet) present in an official D7 release, but there is a patch available to do so in D7 also.

For D7, you can also use the Better Watchdog UI module, which comes with Rules Watchdog Integration. Some more details about this module (from its project page):

Upgrade watchdog entries to entities and replace default database log listing with a view, which grants advanced filtering options and filtered deletion as a bulk operation.

The module creates an entity wrapper around database log entries and enhances the watchdog listing by replacing it with a view. Beside type and severity, additional filter options were introduced such as date and author.

The possibility to change the number of listed entries per page has also been added.

Database clearing has also been customized, now admins can clear only the filtered entries, if needed.

The provided view is accessible to the admins and can be fully customized as any view, to fit one's needs.

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.