in reply to Trap errors at BEGIN

  1. I prefer to write the errors to error.log. It avoids making changes while moving the program from testing to production (always a good thing).

    It also puts other relevant information in close proximity to the messages from my program: The other day I was investing a case where one operation was performed, but the next operation was not. The two subroutine calls were one after another, with no logic statements inbetween. I'd still be banging my head against a wall if I hadn't looked at error_log, and seen that Apache was shut down at that point...

  2. There are a whole bunch of programs which are dedicated to keeping log files manageable. The first that comes to mind is logrotate. That one will rotate your logs on a periodic basis, and keep a specified number of old logs zipped and stored. There are others, including ones that decide to rotate based on the file size.

    One advice: it is a good idea to run a script on such a log that filters out the expected, normal messages, and mails everything else to someone in charge of maintaining the script. After the first week or two, this mail should be usualy empty. If it isn't, you're obviously ignoring problems in your script. That is always the sign of trouble.