How to disable Log4perl output for a specific class?

I would like to use Log4perl in the project, but disable it for a specific class (which in this case is Net :: Amazon). I thought it would be easy, but somehow I failed.

I tried to use

use Log::Log4perl (:easy_init); use Net::Amazon; my $amz = Net::Amazon->new( ... ); my $log = Log::Log4perl->easy_init($DEBUG); $log = $log->get_logger("Net::Amazon"); $log->level($OFF); $log = $log->get_logger(__PACKAGE__); $log->info("Hello World."); 

Unfortunately, Net :: Amazon debugging messages are still printed on the terminal. Why is this? And what am I doing wrong here?

+4
source share
2 answers

The problem is resolved due to human stupidity. I forgot to save the logger for the current package after receiving it using get_logger. The following example works as expected:

 use Log::Log4perl (:easy); use Net::Amazon; my $amz = Net::Amazon->new( ... ); Log::Log4perl->easy_init($DEBUG); $log = get_logger("Net::Amazon"); $log->level($OFF); $log = $log->get_logger(__PACKAGE__); $log->info("Hello World."); 
+2
source

I think you mean

  $log->get_logger("Net::Amazon")->level($OFF) 
+3
source

All Articles