tofu has asked for the wisdom of the Perl Monks concerning the following question:
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:
#untested! open my $fh, "|bin/rotatelogs /var/logs/%y_%m_%d_%H_%M_%S 14400" or di +e "can't open pipe to rotatelogs: $!";
TOFU
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: open FH, "|foo" under modperl2
by perrin (Chancellor) on Feb 06, 2004 at 14:24 UTC | |
|
Re: open FH, "|foo" under modperl2
by Anonymous Monk on Feb 06, 2004 at 21:08 UTC | |
by bart (Canon) on Feb 06, 2004 at 23:21 UTC | |
|
Re: open FH, "|foo" under modperl2
by Anonymous Monk on Feb 06, 2004 at 11:53 UTC | |
by BazB (Priest) on Feb 06, 2004 at 13:32 UTC |