From: Mike S. <msc...@ao...> - 2003-03-03 18:41:36
|
rog...@ea... wrote: > Hi! > > I'm just a log4perl user not a developer. In what forum can I make my > stupid user questions? A log4perl-users list would be nice. You can certainly post any kind of user questions here, with the volume being pretty moderate as of now, we're still able to handle all inquiries in one list. > Here is my first question: > In a module, is it possible to fall back to a STDERR printing log if > the parent program using the module haven't configured a log? > > Like this (not Perl): > #try > { $options->{Log} = Log::Log4perl->get_logger($class); > } > #catch > { Log::Log4perl->easy_init({ > level => $DEBUG, > }); > $options->{Log} = Log::Log4perl->get_logger($class); > } > That's a good question. You could check the variable $Log::Log4perl::INITIALIZED and determine if the main program (or some other module) has initialized Log::Log4perl. If not, you could invoke the init/easy_init methods from within the module. However, you need to make sure all used modules handle this situation in the same way -- if several of them called init/easy_init, modules loaded later would override previous Log4perl settings. -- -- Mike Mike Schilli m...@pe... |