How do I make my Log::Log4perl logger work?
Posted
by Geo
on Stack Overflow
See other posts from Stack Overflow
or by Geo
Published on 2010-05-22T18:46:40Z
Indexed on
2010/05/22
18:50 UTC
Read the original article
Hit count: 280
Here's the code I have:
use strict;
use warnings;
use Log::Log4perl qw(:easy);
Log::Log4perl->init({
level => $DEBUG
});
my $logger = Log::Log4perl->get_logger("my.logger");
my $appender = Log::Log4perl::Appender->new("Log::Log4perl::Appender::File",filename => "my.file");
$appender->layout(Log::Log4perl::Layout::SimpleLayout->new);
$logger->add_appender($appender);
$logger->info("this is an info");
all I want to do is log a message to a file, and have the level show up. I understood that is what the SimpleLayout
is for . I'd like to do this without a configuration file.
Running the code above shows the following message:
Log::Log4perl configuration looks suspicious: No loggers defined
© Stack Overflow or respective owner