On Wed, 18 Feb 2009, wzhao6...@gmail.com 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...@perlmeister.com

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
log4perl-devel mailing list
log4perl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/log4perl-devel

Reply via email to