in reply to Log4perl with my module
I want Emulate.pm's logging behavior to be determined by the Log4perl conf file of the program calling on Emulate.pm.
If Emulate.pm isn't doing anything OO-ish then something like the following should work (untested):
package Emulate; use Log::Log4perl; my $Logger = Log::Log4perl->get_logger( __PACKAGE__ ); ... sub something_that_needs_to_log { $Logger->info('Foo'); }
If Emulate.pm is implementing a class, especially one that's likely to be subclassed, you need to be a little bit more careful about just using __PACKAGE__ as the logging category passed to get_logger(). See the section "Pitfalls with Categories" in the Log::Log4perl docs for more info.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Log4perl with my module
by queeg (Novice) on Dec 31, 2005 at 06:27 UTC |