The common approach to this problem is to
- rename log-file. Like mv file.log file.log.1. The process which holds the old file descriptor open will write to renamed file from this point.
- touch new log file. touch file.log or otherwise create it.
- inform the process. For example, send it SIGHUP or even restart it.
It is not related to perl, I believe.
| [reply] [d/l] [select] |
Ideally, you get that program to do its own log rotation. Second choice is to get it to respond to a SIGHUP as mentioned earlier to close and reopen its log handles (you rename them yourself first, and then send the signal).
Right near the bottom is to create a named pipe (see POSIX::mkfifo / mkfifo) on the log file location first, receiving all of the log entries, and you write them out to the rotating log files. It's moderately evil, but so is 500MB of logging per minute. You just sit there reading from the fifo pipe, and every line you get you can then pipe into Log::Log4perl / Log::Dispatch. You just have to configure these to use Log::Dispatch::FileRotate, and your problem is basically solved. :-) (Still evil, though.)
| [reply] |
take a look to liblogfile-rotate-perl
updated: the original module Rotate packed in liblogfile-rotate-perl, here
| [reply] |
If you can make the program write its log to a file handle (STDOUT, /dev/fd/1), you can use multilog and a simple pipe:
/usr/local/bin/your-program --logfile=/dev/fd/1 | /command/multilog t s100000000 /var/log/your-programs-logdirectory
Alexander
--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
| [reply] [d/l] |