Hi -- I am a new user of MP2 seeking help. I posted this question earlier to the mod-perl list but not get an answer, so perhaps folks here can offer advice...

Here's my situation: My Apache generates 4 sets of logs. Three of them are generated by Apache directly: access, error, and a custom log tracking access for certain files. The fourth is made w/in a MP2 handler; here's the code:

sub mylog { my (@fields) = @_; my $entry = join ( "|", @fields ); open my $fh, ">>" . &MYLOG or die "can't open " . &MYLOG . ": $!"; flock $fh, LOCK_EX; print $fh $entry . "\n"; close $fh; }

Currently I'm rolling my logs "manually" -- a process renames the four sets of logs, waits, then restarts the server, waits, moves away the old logs, etc.

I am considering using piped logs with rotatelogs instead to avoid the restart. I understand how to instruct Apache to log via a pipe to rotatelogs for access and error and custom.

My question relate to the mylog() function:

Thanks very much for your advice and insights....

TOFU


In reply to open FH, "|foo" under modperl2 by tofu

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.