I'm new to Log4perl and am trying to figure out why I get two different loggers in the below setup. My understanding is that this should be a singleton and calling get_logger() would return the same instance of the object each time.
Test.pm
#!/usr/bin/perl
package Example::Test;
use strict;
use warnings;
use Exporter;
our @ISA = qw(Exporter);
our @EXPORT = qw(test);
sub test
{
my $logger = Log::Log4perl->get_logger();
print $logger, "\n";
}
test.pl
#!/usr/bin/perl
use strict;
use warnings;
use Log::Log4perl;
use Example::Test;
# Logger configuration
Log::Log4perl->init('/etc/log4perl.conf');
my $logger = Log::Log4perl->get_logger();
print $logger, "\n";
my $engine = test();
Output
Log::Log4perl::Logger=HASH(0x12093d0)
Log::Log4perl::Logger=HASH(0x29b4950)