From: Vince V. <vi...@ly...> - 2003-07-09 08:40:05
|
Hello Mike Thank's for your quick reply, this works. But I'd like my modules to log into different files absoluteley indepently 'cause I'll have a lot of them working with each other without having a "master" script that controlles them. There will be more than one script that starts stuff and uses them. Therefore every module shall be in charge of it's own logging... Is this against the fundamental idea of log4perl or is there a way to accomplish this? Best regards, Vince mailto:vi...@ly... ----- Tuesday, July 8, 2003, 7:37:05 PM, you 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. MS> init() can be called only once -- preferrably in the main program. Modules MS> you're using should define their logging statements, but should *not* MS> call init(). MS> You might want to write it like this: MS> package A; MS> use Log::Log4perl qw(get_logger); MS> sub run { get_logger("A")->debug("I'm A!"); } MS> package B; MS> use Log::Log4perl qw(get_logger); MS> sub run { get_logger("B")->debug("I'm B!"); } MS> package main; MS> use Log::Log4perl; Log::Log4perl->>init(\ <<'EOT'); MS> log4perl.category.A = DEBUG, LogfileA MS> log4perl.appender.LogfileA = Log::Log4perl::Appender::File MS> log4perl.appender.LogfileA.filename = a.log MS> log4perl.appender.LogfileA.layout = SimpleLayout MS> log4perl.category.B = DEBUG, LogfileB MS> log4perl.appender.LogfileB = Log::Log4perl::Appender::File MS> log4perl.appender.LogfileB.filename = b.log MS> log4perl.appender.LogfileB.layout = SimpleLayout MS> EOT MS> A::run(); MS> B::run(); MS> __END__ MS> -- Mike MS> Mike Schilli MS> log...@pe... MS> http://perlmeister.com MS> http://log4perl.sourceforge.net MS> ------------------------------------------------------- MS> This SF.Net email sponsored by: Parasoft MS> Error proof Web apps, automate testing & more. MS> Download & eval WebKing and get a free book. MS> www.parasoft.com/bulletproofapps MS> _______________________________________________ MS> log4perl-devel mailing list MS> log...@li... MS> https://lists.sourceforge.net/lists/listinfo/log4perl-devel |