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.


In reply to Re: Trap errors at BEGIN by matija
in thread Trap errors at BEGIN by kiat

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.