GB has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to use log4perl and I want to log in a module which is called from multiple different script files. Irrespective of who the caller is, the module should log the message to that particular callers adapter/log file. Can this be achieved?
testPackage.pmmy $conf = q( + log4perl.logger.testLog = ).$logging_level.q(, logApp log4perl.appender.logApp= Log::Log4perl::Appender::File + log4perl.appender.logApp.mode= append log4perl.appender.logApp.syswrite= 1 log4perl.appender.logApp.filename= test.log + log4perl.appender.logApp.layout= Log::Log4perl::Layout::Pa +tternLayout log4perl.appender.logApp.layout.ConversionPattern = %m % +n ) Log::Log4perl->init( \$conf ); + use testPackage; + &testPackage::foo();
Can some monks please see this and bestow the light on this.package testPackage; use Log::Log4perl qw(get_logger); sub foo { $logger = Log::Log4perl->get_logger(""); # IF I PUT testLog IN TH +E QUOTES THEN I'M GETTING THE blah IN THE CALLERS LOGS FILE $logger->info("blah"); } 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: log4perl in module appending to callers log file
by Khen1950fx (Canon) on Jul 28, 2011 at 04:21 UTC | |
|
Re: log4perl in module appending to callers log file
by wwe (Friar) on Jul 28, 2011 at 13:22 UTC | |
by GB (Initiate) on Jul 28, 2011 at 14:49 UTC | |
by wwe (Friar) on Aug 02, 2011 at 09:29 UTC |