Watching the Watchdog

Photo of Greg Harvey
Sun, 2008-01-13 20:41By greg

The Watchdog is an incredibly useful feature of Drupal. A catch-all (or as much of all as you might want it to) system logger, invaluable for de-bugging and all sorts of other smart things too, like access information, PHP warnings, last cron runs, etc.

The problem with Watchdog is it can get very VERY large. Very quickly. That's exactly why Watchdog, by default, only keeps a couple of week's-worth of data. But sometimes even this is too much.

I started to upload the mysqldump of a database for a new application I'd been working on recently. It seemed to be taking a very long time for a clean installation. I'd been developing on it, of course, but it hadn't occurred to me to check the size of the catalogue.

Well, the reason it was so slow was the catalogue size had reached nearly 400MB. Abort!!!

Examination of the catalogue revealed that 398MB of this was in the 'watchdog' table. I checked the data using the MySQL admin tools (the actual Watchdog page won't work very well when the table is 398MB in size) and there was nothing especially remarkable. Just all the usual sort of stuff you might expect - errors from typos, warnings here, notifications there. But it mounts up quickly when you're developing.

So, my tip of the day is ALWAYS truncate the 'watchdog' table before you commit your application in to Production for the first time. Here endeth the (probably unnecessary) lesson.