How can I suppress output on stdout and stderr in Log4perl?

I have this sub to initialize my registrar:

sub initLogfiles{ Log::Log4perl->easy_init($INFO); # We log all debug, info, warn, error and fatal messages. my $userlogappender = Log::Log4perl::Appender->new( "Log::Log4perl::Appender::File", filename => USERLOGFILE, mode => "append", recreate => 1 ); my $userloglayout = Log::Log4perl::Layout::PatternLayout->new("%d;%m%n"); $userlogappender->layout($userloglayout); $userlogger->add_appender($userlogappender); } 

I only need to have loginfo in my log file. How can I prevent this from entering stdout?

+4
source share
2 answers

I found him. I have to add this line to my subsection:

 $userlogger->additivity(0); 

I found the answer here: log4perl FAQ

+6
source

Log :: Log4perl-> easy_init () initializes the library using ScreenAppender, so the log is sent to stdout.

Delete it and add the following to write all the logs (debug level and above) to the file:

  Log::Log4perl->get_logger()->level($DEBUG); 
+5
source

All Articles