From: Kevin G. <ke...@go...> - 2002-11-18 19:09:12
|
Stylin! I've added a map to the log4j syntax so it can be set up like this: log4j.appender.apndr=org.apache.log4j.RollingFileAppender log4j.appender.apndr.File=app.log log4j.appender.apndr.MaxFileSize=15_000_000 log4j.appender.apndr.MaxBackupIndex=2 log4j.appender.apndr.layout=org.apache.log4j.SimpleLayout I don't suppose you have an overwhelming urge to implement DailyRollingFileAppender while you're at it? mark pfeiffer wrote: > 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 -- Happy Trails . . . Kevin M. Goess (and Anne and Frank) 904 Carmel Ave. Albany, CA 94706 (510) 525-5217 |