fionbarr has asked for the wisdom of the Perl Monks concerning the following question:

I want to keep using a log file until its size>15m. Right now the existing parameters create a new log file each time my program starts...what do I put in the config file to tell it to use the same file until the size is greater than the max?
log4perl.category.fileLogger=INFO, LOGFILE # write to rotating log file log4perl.appender.LOGFILE=Log::Dispatch::FileRotate # log settings log4perl.appender.LOGFILE.filename=/home/user/xxx/review/code_ +review.log log4perl.appender.LOGFILE.size=15M log4perl.appender.LOGFILE.max=15 log4perl.appender.LOGFILE.mode=append # log file format; see +.35/lib/Log/ log4perl.appender.LOGFILE.layout=PatternLayout log4perl.appender.LOGFILE.layout.ConversionPattern=[%d (%P) %rms %p] % +m%n log4perl.appender.LOGFILE.layout.ConversionPattern=[%d] %p %m%n

Replies are listed 'Best First'.
Re: parameter for log4perl
by Khen1950fx (Canon) on Jun 12, 2012 at 14:31 UTC
    I would cleanup a bit:
    #!/usr/bin/perl -l use strict; use warnings; use Log::Dispatch::FileRotate; use Log::Log4perl qw(get_logger); my $conf = q( log4perl.category.fileLogger = INFO, Logfile log4perl.appender.Logfile = Log::Dispatch::FileRotate log4perl.appender.Logfile.filename = code_review.log log4perl.appender.Logfile.mode = append log4perl.appender.Logfile.max = 15 log4perl.appender.Logfile.size = 15000 log4perl.appender.Logfile.layout = \ Log::Log4perl::Layout::PatternLayout log4perl.appender.Logfile.layout.ConversionPattern = \ [%d (%P) %rms %p] %m%n ); Log::Log4perl->init( \$conf );
      thanks to both
Re: parameter for log4perl
by chrestomanci (Priest) on Jun 12, 2012 at 12:51 UTC

    Use Log::Dispatch::FileRotate

    If you don't supply a date pattern for log rotation, it will rotate by file size instead, so when the log file reaches 10 Meg (or whatever size you specify) it will rotate the log file & start a new one.