From: Mike S. <m...@pe...> - 2011-08-18 03:35:44
|
On Wed, 17 Aug 2011, Richard Thomas wrote: > Do you know if anyone has had any success with using Log4perl in > Strawberry Perl? Yes, it works with Strawberry Perl. > The reason I ask is that I'm using Strawberry Perl for the first time > and a script that normally works in Activestate Perl is not working in > Strawberry Perl. You're using a 3rd party appender, Log::Dispatch::FileRotate appender, which isn't part of Log4perl. While I know that Log4perl works with Strawberry Perl, I don't know about 3rd party appenders. Can you give it a try using Log::Log4perl::Appender::File instead? Also, make sure you're using the latest Log4perl from CPAN. -- -- Mike Mike Schilli m...@pe... > > The error I get is "undefined value provided for log level at > C:/strawberry/perl/site/lib/Log/Log4perl/Appender.pm line 80". > > I've extracted some lines on my script below, so you can see how I setup and use > Log4perl. > > Please could you let me know if you can think of anything I can try to get this > working. > > Thanks, > > Richard. > > > > > use strict; > use warnings; > > use Date::Manip; > use Log::Log4perl; > > use Storable; > > use String::Parity; > use String::Parity qw(:DEFAULT /show/); > > use IO::Socket; > use Time::HiRes qw(time); > <snip> > my $log_conf1 = q/ > log4perl.category = INFO, Logfile, Logscreen > log4perl.appender.Logfile = Log::Dispatch::FileRotate > log4perl.appender.Logfile.filename = /; > > my $log_conf2 = q/ > log4perl.appender.Logfile.mode = append > log4perl.appender.Logfile.DatePattern = yyyy-mm-dd > log4perl.appender.Logfile.TZ = GMT0BST > log4perl.appender.Logfile.layout = > Log::Log4perl::Layout::PatternLayout > log4perl.appender.Logfile.layout.ConversionPattern = %d %m %n > > log4perl.appender.Logscreen = > Log::Log4perl::Appender::Screen > log4perl.appender.Logscreen.str = 0 > log4perl.appender.Logscreen.layout = > Log::Log4perl::Layout::PatternLayout > log4perl.appender.Logscreen.layout.ConversionPattern = %m %n > > /; > > my$log_conf=sprintf("%s%s.%s.log\n%s",$log_conf1,$ScriptNoExt,$dateformat,$log_conf > 2); > > Log::Log4perl::init( \$log_conf ); > > my $logger = Log::Log4perl::get_logger(); > <snip> > > |