Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

parameter for log4perl

by fionbarr (Friar)
on Jun 12, 2012 at 12:43 UTC ( #975768=perlquestion: print w/replies, xml ) Need Help??

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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://975768]
Front-paged by Corion
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (5)
As of 2020-11-24 03:30 GMT
Find Nodes?
    Voting Booth?

    No recent polls found