From: Reinhold R. <rei...@gm...> - 2003-09-11 16:03:57
|
Hi all, first of all thanks to Kevin and Mike helping me to solve my latest problem: change the log output file at runtime. I wrote a new class, derived form Log::Log4perl::Appender::File and I'm happy that it works. Now, my daemon is ready to run. all users using this daemin are able to configure their loglevel themselves. so I also change the loglevel at runtime using the functions dec_level() and inc_level(). At the first time, I missed a function for setting the new loglevel directly. So I wrote the follwing function that does the work for me: sub set_level ($$) { my $logger = shift; my $new_level = shift; while ($logger->level() != $new_level) { if ($logger->level() < $new_level) { $logger->inc_level(); } else { $logger->dec_level(); } } } #--- set_level I don't know if there exists a better solution than this. If so, let me know please. but incrementing an decrementing loglevel at runtime made my program run very slow after a short time. I wrote the follwing little program to test the memory behavior of the above functions: #!/usr/bin/perl use strict; use Log::Log4perl qw(:easy); use Log::Log4perl qw(:levels); use Log::Dispatch::Screen; use Log::Log4perl::Appender; #------------------------------------------------------------------- Log::Log4perl->easy_init ($ERROR); my $logger = get_logger(); while (1) { $logger->dec_level(); $logger->inc_level(); } #--------------------------------------------------------------------- I started it and looked at the mem usage of the process. It was increasing very quickly. Maybe it is a bug, or am I using this functions not correctly in my test program?? many thanks for your help. greetings Reinhold -- COMPUTERBILD 15/03: Premium-e-mail-Dienste im Test -------------------------------------------------- 1. GMX TopMail - Platz 1 und Testsieger! 2. GMX ProMail - Platz 2 und Preis-Qualitätssieger! 3. Arcor - 4. web.de - 5. T-Online - 6. freenet.de - 7. daybyday - 8. e-Post |