Actually, the way Log4perl works (it is singleton), get_logger () will return the same object, wherever you call it from
use Log::Log4perl qw(:easy); Log::Log4perl->easy_init( $ERROR ); print Log::Log4perl->get_logger("MyLog"), "\n"; package Some::Other::Package; print Log::Log4perl->get_logger("MyLog"), "\n";
Prints (for example):
Log::Log4perl::Logger=HASH(0x15a9d48) Log::Log4perl::Logger=HASH(0x15a9d48)
So, if you want to use the same $ log for all your modules, you can simply call get_logger ("MyLog") in each of these modules.
But the best way, if you want to enable or disable logging in one specific module, may be to simply call get_logger () with no arguments. This will return a registrar bound to the current package name so that you can enable or disable this packet recorder in your configuration file.
source share