I want to write ERROR message to a file, and write DEBUG message to stderr, then I write the following code:
#!/usr/bin/perl
use strict;
use warnings;
use Log::Log4perl qw(:easy);
Log::Log4perl->easy_init(
{
file => ">> error_log",
level => $ERROR,
},
{
file => "STDERR",
level => $DEBUG,
}
);
ERROR( "ERROR MESSAGE" );
DEBUG( "DEBUG MESSAGE" );
When I run the above code, the message ERROR MESSAGE and DEBUG MESSAGE write to both file and stderr, can anyone explain why?