From: Mike S. <log...@pe...> - 2003-07-08 17:38:08
|
On Tue, 8 Jul 2003, Vince Veggus wrote: > I want my module a.pm to log into a.log, b.pm into b.log. > I call init(a.conf) and getLogger() in the Constructor of a. > I call init(b.conf) and getLogger() in the Constructor of b. > My run.pl uses a and b, a->run() an b->run() log something into > a.log and b.log. > But after calling a->run() b->run() logs into a.log too. init() can be called only once -- preferrably in the main program. Modules you're using should define their logging statements, but should *not* call init(). You might want to write it like this: package A; use Log::Log4perl qw(get_logger); sub run { get_logger("A")->debug("I'm A!"); } package B; use Log::Log4perl qw(get_logger); sub run { get_logger("B")->debug("I'm B!"); } package main; use Log::Log4perl; Log::Log4perl->init(\ <<'EOT'); log4perl.category.A = DEBUG, LogfileA log4perl.appender.LogfileA = Log::Log4perl::Appender::File log4perl.appender.LogfileA.filename = a.log log4perl.appender.LogfileA.layout = SimpleLayout log4perl.category.B = DEBUG, LogfileB log4perl.appender.LogfileB = Log::Log4perl::Appender::File log4perl.appender.LogfileB.filename = b.log log4perl.appender.LogfileB.layout = SimpleLayout EOT A::run(); B::run(); __END__ -- Mike Mike Schilli log...@pe... http://perlmeister.com http://log4perl.sourceforge.net |