loris has asked for the wisdom of the Perl Monks concerning the following question:

Hello all,

In a module I have

use Log::Log4perl qw(get_logger); our $log = Log::Log4perl->get_logger(__PACKAGE__);

I do

Log::Log4perl->init("log.conf");

in a script which uses the module. This works OK, but when I test the module with a script which does not initialise the logging mechanism I get, logically enough,

Log4perl: Seems like no initialization happened. Forgot to call init() +?

Is there a smart way to switch off the logging when I'm testing? Or should I just go the whole log-hog and log the tests? If the latter, why?

Thanks,

loris

Replies are listed 'Best First'.
Re: Simple::Testing and Log::Log4perling
by saintmike (Vicar) on Nov 24, 2004 at 09:12 UTC
    You can have Log::Log4perl suppress the warning by including the :nowarn target when calling use in your module code:
    use Log::Log4perl qw(get_logger :nowarn);
    More on this topic can be found in this FAQ.
Re: Simple::Testing and Log::Log4perling
by aquarium (Curate) on Nov 24, 2004 at 10:19 UTC
    on unix machine set your log file to /dev/null
    the hardest line to type correctly is: stty erase ^H