From: Mike S. <m...@pe...> - 2005-07-06 01:42:40
|
On Tue, 5 Jul 2005, Rob Redmon wrote: > I'm new to log4perl/log4j. My goal is to have a few different running > perl programs write to the same log file, perhaps simultaneously. To > test that ability, I wrote the simple perl program and log given below. > Then I kicked off (i.e. bash> test_log4perl.pl &) the perl program 10 > times so they'd all be running simultaneously. I noticed in my > resulting log file that the filename %F is occasionally given as "(eval > 61)" and the method name is shown as "Log::Log4perl::Logger::__ANON__". > Specifically, I'm expecting this log message: > 2005/07/05 13:18:10 INFO > test_log4perl.pl(pid=24623):30 main:: - i= > 988 slept for 0 of 0 seconds > > And occasionally, I'm getting one like this: > 2005/07/05 12:25:18 INFO > (eval 61)(pid=24263):42 > Log::Log4perl::Logger::__ANON__ - i= 243 slept for 1.64915744429506 of 1 > seconds Hi Rob, I'm not entirely sure why you're getting "eval" as the file name (are you modifying the conf file while you're running the test?), but to sychronize access to a single log file used by multiple processes, please use the method described in http://log4perl.sourceforge.net/d/Log/Log4perl/FAQ.html#23804 -- Mike Mike Schilli m...@pe... > Hi, > > I'm new to log4perl/log4j. My goal is to have a few different running > perl programs write to the same log file, perhaps simultaneously. To > test that ability, I wrote the simple perl program and log given below. > Then I kicked off (i.e. bash> test_log4perl.pl &) the perl program 10 > times so they'd all be running simultaneously. I noticed in my > resulting log file that the filename %F is occasionally given as "(eval > 61)" and the method name is shown as "Log::Log4perl::Logger::__ANON__". > Specifically, I'm expecting this log message: > 2005/07/05 13:18:10 INFO > test_log4perl.pl(pid=24623):30 main:: - i= > 988 slept for 0 of 0 seconds > > And occasionally, I'm getting one like this: > 2005/07/05 12:25:18 INFO > (eval 61)(pid=24263):42 > Log::Log4perl::Logger::__ANON__ - i= 243 slept for 1.64915744429506 of 1 > seconds > > The log config and perl program follow. Any help appreciated! > > ######## log config ######### > # > # Author: Rob Redmon > # Rob...@no... > # > log4perl.logger.Ionosonde=DEBUG, Logfile > log4perl.appender.Logfile=Log::Dispatch::FileRotate > log4perl.appender.Logfile.filename=log/load_sec.log > log4perl.appender.Logfile.mode=append > log4perl.appender.Logfile.layout=Log::Log4perl::Layout::PatternLayout > log4perl.appender.Logfile.layout.ConversionPattern=%d %p > > %F{1}(pid=%P):%L %M - %m%n > log4perl.appender.Logfile.max=366 > #have to choose by size or date, not both: > #log4perl.appender.Logfile.size=1 > log4perl.appender.Logfile.DatePattern = yyyy-MM-dd > log4perl.appender.Logfile.TZ = MST > > > ######## simple perl ######## > #!/usr/bin/perl > > use strict; > use warnings; > use lib '../../lib/perl'; > > use IO::Dir; > #use Log::Log4perl qw(:easy); > use Log::Log4perl qw(get_logger :levels); > > local *__ANON__ = "test_log4perl.pl"; > > #Log::Log4perl->easy_init($INFO); > Log::Log4perl->init_and_watch("log.conf", 60); #recheck config file > every 60 seconds > > ##### > # Config > ##### > my $logger = get_logger("Ionosonde"); > $logger->level($DEBUG); > > ##### > # Test > ##### > $logger->info("Testing log4perl: START"); > > for (my $i=0; $i<1000; $i++) { > my $t_sec = rand(2); > my $n_sec = sleep($t_sec); > $logger->info("i= ",$i," slept for ",$t_sec," of ",$n_sec," seconds"); > } > > $logger->info("Testing log4perl: END"); > > -- > Rob Redmon > NOAA/NGDC > 325 Broadway E/GC2 > Boulder, Colorado 80305 > Tel: (303) 497-4331 > Fax: (303) 497-6513 > Rob...@no... > > "Engineering is the art of making what you want from things you can get." > > > > ------------------------------------------------------- > SF.Net email is sponsored by: Discover Easy Linux Migration Strategies > from IBM. Find simple to follow Roadmaps, straightforward articles, > informative Webcasts and more! Get everything you need to get up to > speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click > _______________________________________________ > log4perl-devel mailing list > log...@li... > https://lists.sourceforge.net/lists/listinfo/log4perl-devel > |