From: Mike S. <m...@pe...> - 2009-02-20 05:41:41
|
On Wed, 18 Feb 2009, wzh...@gm... wrote: > I have a script running, which can be stopped and restarted frequently. I > was able to get the file rotation working until I added > "log4perl.appender.RunMonitorLogFile.mode = append" to set the mode to > append, so the previous script run's log file doesn't get wiped out after a > restart of the script. It's not rotating anymore. Works for me. Here's a script for you to verify, call it a couple of times, then wait a minute, and call it again, and you'll see that it'll create test.log.1, test.log.2 etc. use strict; use Log::Log4perl qw(get_logger); my $conf = q( log4perl.category.Bar.Twix = WARN, Logfile log4perl.appender.Logfile = Log::Dispatch::FileRotate log4perl.appender.Logfile.filename = test.log log4perl.appender.Logfile.mode = append log4perl.appender.Logfile.DatePattern = yyyy-MM-dd-HH-MM log4perl.appender.Logfile.max = 5 log4perl.appender.Logfile.layout = \ Log::Log4perl::Layout::PatternLayout log4perl.appender.Logfile.layout.ConversionPattern = %d %m %n ); Log::Log4perl::init(\$conf); my $logger = get_logger("Bar::Twix"); $logger->error("Blah"); Try it out! -- Mike Mike Schilli m...@pe... |