In my last post I wrote about how an extremely bloated PHP log file was taking up more than it's fair share of my hard drive. I found it and deleted it, but what's to keep it from happening again? If I were ambitious I could find all the code that's writing to that file and delete it. However, I do sometimes refer to these error messages while debugging my code, and I'd rather not eliminate this information. However, when I do read this log file I'm usually looking at the most recent entries. I don't need a 6 month old records of my mistakes.

I decided to use one of my favorite utilities, Hazel. Again, from their home page:

I usually use Hazel to help automate a paperless workflow, mostly following the rules outlined in David Spark's Paperless book. I think I could write a book about ways to use Hazel (there's so many possibilities!) , but today I'll just show you how I addressed the problem of the swollen log files:

Hazel rule - click for larger image

In other words, I told Hazel to watch the directory with the log files. If any file gets larger than 1GB, move it into the trash. Easy-peasy.

Now I can make as many coding errors as I like without worrying about this file growing to occupy 1/5 of my hard drive.