Skip Menu |

This queue is for tickets about the Log-Log4perl CPAN distribution.

Report information
The Basics
Id: 60386
Status: resolved
Priority: 0/
Queue: Log-Log4perl

People
Owner: Nobody in particular
Requestors: mitjabartsch [...] gmx.de
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.29
Fixed in: (no value)



Subject: uninitialized value when using init_and_watch
After updating from Log4perl 1.27 to 1.29 I was encountered with warning messages "Use of uninitialized value in exists at /usr/lib/perl5/site_perl/5.8.8/Log/Log4perl/Layout/PatternLayout.pm line 187". The uninitialized variables are in my case %F and %L (Format specifiers for the PatternLayout).It happens when using the initialization function init_and_watch() after the first new initialization. Switching back to version 1.27 solved the problem. I attach a short script that produces these warnings and shows the way I used Log4perl. My operating system is OpenSuse 10.3 With best regards Mitja Bartsch
Subject: test1.pl
#!/usr/bin/perl -w use Log::Log4perl qw(:levels get_logger); my $cnf = '/tmp/test.cnf'; write_cnf($cnf); Log::Log4perl::init_and_watch($cnf,10); my $logger = get_logger(); my $i = 0; while () { $logger->info("$i: arbitrary message"); sleep 1; $i++; unless ($i%30) { write_cnf($cnf); } } sub write_cnf { print "writing logging configuration\n"; my $cnf = shift; my $logpath = '/tmp/test_log'; mkdir $logpath unless -e $logpath; my ($logfile) = reverse glob ($logpath.'/test[0-9].log'); if ($logfile) { $logfile =~ /test(\d+)\.log/; my $nr = $1; $nr++; $logfile = $logpath.sprintf("/test%01d.log", $nr%10); } else { $logfile = $logpath.'/test0.log'; } print $logfile,"\n"; open CNF, ">$cnf"; print CNF << "EOF"; log4perl.rootLogger=INFO, LOGFILE log4perl.appender.LOGFILE=Log::Dispatch::File log4perl.appender.LOGFILE.filename=$logfile log4perl.appender.LOGFILE.layout=PatternLayout log4perl.appender.LOGFILE.layout.ConversionPattern=%d{yy/DDD HH:mm:ss} - %R - %-5p> %-30F{1}:%4L - %m%n EOF close CNF; }
Great find, thanks for the detailed report! I went ahead and fixed it for 1.30: http://github.com/mschilli/log4perl/commit/2474d02d164de987de4c582f30e082218692fca8 -- Mike