From: Mike S. <m...@pe...> - 2004-10-17 21:00:53
|
On Sun, 17 Oct 2004, Richard Lippmann wrote: > I like Log::Log4perl more and more. Great :) > But I have a problem changing > loglevel in my program. I do this for config Log::Log4perl: > > my $log_conf = q/ > log4perl.category = INFO, Logfile, Screen > ... > log4perl.logger.main = INFO > log4perl.logger.Hob.ReorderFiles = INFO > log4perl.logger.Hob.Inventory = INFO > log4perl.logger.Hob.GetWishlist = INFO > log4perl.logger.Hob.Harvester = INFO > /; > > Now I want to set loglevel form Hob.Harvester to "DEBUG" because there > is a record for this in my config(xml)file for the programm. How do I do > that? > > I could do this: > > my $logger = Log::Log4perl->get_logger('Hob.Harvester'); > $logger->more_logging(2); > > But I would love to do this: > > $logger->set_loglevel_to(DEBUG) Log4perl is highly optimized for speed, so if you change a level manually, it has to redo its optimizations. Here's a (undocumented) way to do that: use Log::Log4perl qw(:levels); # ... my $logger = Log::Log4perl->get_logger('Hob.Harvester'); $logger->level($DEBUG); $logger->set_output_methods; Along with more_logging() and less_logging(), we should probably provide a reassign_level() method for the loggers ... -- Mike Mike Schilli m...@pe... |