function to clear the watchdog log?

by chrisjlee   Last Updated January 11, 2018 15:07 PM

Is there a drupal function to clear the watchdog log inside a module?

Tags : 7


Answers 3


The best way to do this is via drush:

$ drush help watchdog-delete
Delete watchdog messages. Arguments or options must be provided to specify which messages to delete.

Examples:
 drush watchdog-delete all                 Delete all messages.
 drush watchdog-delete 64                  Delete messages with id 64.
 drush watchdog-delete "cron run           Delete messages containing the string "cron run succesful".
 succesful"
 drush watchdog-delete --severity=notice   Delete all messages with a severity of notice.
 drush watchdog-delete --type=cron         Delete all messages of type cron.


Arguments:
 severity                                  Delete messages of a given severity level.
 type                                      Delete messages of a given type.


Aliases: wd-del, wd-delete
mpdonadio
mpdonadio
January 04, 2012 15:23 PM

db_delete('watchdog')->execute();
xandeadx
xandeadx
January 04, 2012 15:34 PM

add -y to command: drush watchdog-delete all

==> drush watchdog-delete all -y

Abdeladhim Sahraoui
Abdeladhim Sahraoui
January 11, 2018 15:03 PM

Related Questions