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
In reply to open FH, "|foo" under modperl2 by tofu
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |