Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have this sub to initialize my logger:

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 want to have the loginfo in my logfile. How do i prevent this from logging to stdout?

like image 787
Allan Simonsen Avatar asked Dec 23 '22 09:12

Allan Simonsen


1 Answers

I found it. I have to add this line to my sub:

$userlogger->additivity(0);

I found the answer here: log4perl FAQ

like image 155
Allan Simonsen Avatar answered Dec 24 '22 22:12

Allan Simonsen