From: mark p. <mar...@ed...> - 2002-11-18 06:33:58
|
A new version has just been uploaded to PAUSE: M/MA/MARKPF/Log-Dispatch-FileRotate-1.03.tar.gz should handle multiple writers. On Mon, 18 Nov 2002 09:23:02 +1100 mark pfeiffer's good news was: > > Thanks for the feedback Kevin. I'll chase up your leads and do some > proper testing... What you are saying is absolutely correct! > > On Fri, 15 Nov 2002 10:35:19 -0800 Kevin Goess's good news was: > > Mark, nice job and thanks, but how are you handling multiple processes > > writing to the same log file? If you have a web server with 20 children > > logging to the same file, you're going to get race conditions like this: > > > > child1: hey, the log file is too big, time to rotate! > > child2: hey, the log file is too big, time to rotate! > > child1: renames current file to backup > > child2: renames empty current file to backup, kiboshes data > > > > That's why the apache utilities cronolog and rotatelogs both take the > > strategy of just writing to a different file after the cutoff, leaving > > the old file alone. I think the log4j method works for log4j because > > they typically only one JVM per machine and thus only one singleton logger. > > > > To do it the log4j way, we'd need to lock the log file before messing > > with it. (Actually, if we're renaming it, we need to keep the lock on a > > separate file). See the floc docs under perlfaq5 or File::Lock or maybe > > Logfile::Rotate, which looks like it uses locks, might be useful. > > > > What do you think? > > ... snip ... cheers mark |