palette has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I wanted to create a logfile on the fly using Log4perl.
I am having the following lines in my code
In the module the call to the conf file
the error reads something like this while executing the testscript.
I wanted to create a logfile on the fly using Log4perl.
I am having the following lines in my code
log4perl.logger.ClassA = DEBUG, ClassA log4perl.appender.ClassA = Log::Log4perl::App +ender::File log4perl.appender.ClassA.filename = \ sub { my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = l +ocaltime time; my $date=sprintf("%04d%02d%02d",1900+$year,$mon+1,$mday); my $log_file="/tmp/ClassA".$date.".log"; return $log_file; }
In the module the call to the conf file
But when this module is called from the testscript able to see the following error.BEGIN { Log::Log4perl::init_and_watch('/etc/log4perl.conf',5); $__PACKAGE__::mylog=Log::Log4perl->get_logger(); }
the error reads something like this while executing the testscript.
# in classa.t at line 8. # Tried to use 'ClassA'. # Error: Can't evaluate 'sub {' (Missing right curly or square b +racket at (eval 136) line 2, at end of line # syntax error at (eval 136) line 2, at EOF # ) at /usr/local/lib/perl5/site_perl/5.8.5/Log/Log4perl/Config.pm lin +e 715.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: log file in Log4perl
by Melly (Chaplain) on Jan 12, 2007 at 12:12 UTC | |
Re: log file in Log4perl
by Anonymous Monk on Jan 12, 2007 at 11:39 UTC | |
by palette (Scribe) on Jan 12, 2007 at 11:57 UTC | |
by ferreira (Chaplain) on Jan 12, 2007 at 12:07 UTC | |
by jasonk (Parson) on Jan 12, 2007 at 14:23 UTC |
Back to
Seekers of Perl Wisdom