CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
log4perl seems not to work as advertised

 



zatlas1
Novice

Mar 19, 2012, 3:10 PM

Post #1 of 5 (7101 views)
log4perl seems not to work as advertised Can't Post

Hi All

I have this sample program:


Code
  

use strict;
use warnings;
use Log::Dispatch::FileRotate;
use Log::Log4perl qw(:easy);
my $config = $ENV{'CONFIGPATH'};
Log::Log4perl::init( "$config$\/testRotate\.conf" );
my $logger = Log::Log4perl->get_logger;
for (my $i = 1; $i<10000000;$i++)
{
$logger->info ("TESTING ROTATE $i for 10,000,000 times");
}



and this config file:

# testRotate-logger.conf
log4perl.rootLogger = INFO, AE
log4perl.appender.AE = Log::Dispatch::FileRotate

log_dir = /mydir/logs/
log4perl.appender.AE.filename = ${log_dir}/testRotate.log
log4perl.appender.AE.mode = append
log4perl.appender.AE.Logfile.max = 5
log4perl.appender.AE.Logfile.size = 1000000
log4perl.appender.AE.layout = Log::Log4perl::Layout::PatternLayout
log4perl.appender.AE.layout.ConversionPattern = %d %p %m %n

The Logfile.max and Logfile.size just don't work and the package seems to ignore them and use 2 files and 10000000 size

any idea


BillKSmith
Veteran

Mar 19, 2012, 4:39 PM

Post #2 of 5 (7099 views)
Re: [zatlas1] log4perl seems not to work as advertised [In reply to] Can't Post


Quote

Code
Log::Log4perl::init( "$config$\/testRotate\.conf" );   




This statement probably produces a run-time warning. Perl tries to form the file name by concatening the contents of the scalar variable $config (which does not exist) with the special variable $\ and then with '/testRotate.conf'

I am not sure what you intend. You must fix the quotes and escapes to specify what you really mean.
Good Luck,
Bill


zatlas1
Novice

Mar 20, 2012, 7:12 AM

Post #3 of 5 (7082 views)
Re: [BillKSmith] log4perl seems not to work as advertised [In reply to] Can't Post

$config actually exists and is correct

my $config = $ENV{'CONFIGPATH'};

the string

$\/testRotate\.conf

is obviously a mistake (I left a code from previous attempt to resolve the issue) so the correct line is:
Log::Log4perl::init( "$config\/testRotate\.conf" );

which corretly points to the configuration file above.


BTW, I tried with and without the 'easy' option, with and without the 'INFO' instead of $logger->info, etc. None changed the behavior of ignoring the 'size' and 'max' attributes in the configuration file.

log4perl still appears not to be working as advertised!!!

Thanks

ZA


(This post was edited by zatlas1 on Mar 20, 2012, 7:20 AM)


BillKSmith
Veteran

Mar 20, 2012, 11:18 AM

Post #4 of 5 (7062 views)
Re: [zatlas1] log4perl seems not to work as advertised [In reply to] Can't Post

Sorry, I cannot help with the module. The filename looked wrong so I wrote a tiny script to confirm its behavior. ($config did not exist in my script and I forgot to check in the original).
Good Luck,
Bill


zatlas1
Novice

Mar 22, 2012, 11:24 AM

Post #5 of 5 (7032 views)
Re: [BillKSmith] log4perl seems not to work as advertised [In reply to] Can't Post

Error resolved:

log4perl.appender.AE.max = 5
log4perl.appender.AE.size = 1000000

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives