From: Vince V. <vi...@ly...> - 2003-07-08 11:05:20
|
Hello, 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. Why? Where's my mistake? The modules are available at http://www.nomorepasting.com/paste.php?pasteID=5969 -- Best regards, Vince mailto:vi...@ly... |
From: Vince V. <vi...@ly...> - 2003-07-08 13:22:27
|
Hello, 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. Why? Where's my mistake? The modules are available at http://www.nomorepasting.com/paste.php?pasteID=5969 any hint is welcom, best regards, Vince |
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 |
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 |
From: Mike S. <log...@pe...> - 2003-07-14 20:35:28
|
On Wed, 9 Jul 2003, Vince Veggus wrote: > 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? Sorry for the long wait, here's a couple of thoughts on this: There's currently no way in Log::Log4perl to load more than one config file or to append configuration statements to a loaded configuration. This could be changed, however, if we find a proper way of dealing with the following implications: The big problem with having libraries add their share to the L4P configuration is that there's no easy way of preventing them from stepping on each other's feet. What if lib A defines an appender named "File" and lib B defines a different appender under the same name? What if the main application wants to take control over lib X's L4P configuration? How could lib X possibly know what kind of application it is going to run in and what the l4p configuration requirements are? Ideas? -- Mike Mike Schilli log...@pe... http://perlmeister.com http://log4perl.sourceforge.net |
From: Jim C. <jc...@di...> - 2003-07-18 21:12:57
|
Mike Schilli wrote: >There's currently no way in Log::Log4perl to load more than one config file >or to append configuration statements to a loaded configuration. This could >be changed, however, if we find a proper way of dealing with the following >implications: > >The big problem with having libraries add their share to the L4P configuration >is that there's no easy way of preventing them from stepping on each >other's feet. What if lib A defines an appender named "File" and lib B >defines a different appender under the same name? What if the main application >wants to take control over lib X's L4P configuration? How could lib X >possibly know what kind of application it is going to run in and what the >l4p configuration requirements are? > >Ideas? > >-- Mike > > > > It strikes me that this problem is not Log4perls responsibility. Consider it as similar to C #include; # include "macros.h"; /* which defines foo() amongst other things */ /* now alter the standard foo macro, for our own purposes */ #undef foo #define foo(a,b) bar(a,b) this isnt the best way to handle all such situations, but its certainly usefull sometimes. # strawman include syntax - it should 'be' a function, but it can look like an assignment. # baseline config - not automatically used - done explicitly by user. log4perl.include = X-subsys-logging-config log4perl.include = Y-subsys-logging-config # testing-config - overrides etc.. log4perl.include = X-subsys-logging-config-test-overrides log4perl.include = Y-subsys-logging-config-test-overrides # now further override selected pieces. log4perl.category.X.foo = INFO log4perl.category.Y.bar = INFO By doing this, each subsystem can define its 'typical' usage, and provide several useful override-files, which can be selectively used by the main script. # we can even control reporting/dieing/etc of such overrides log4perl.include.override = warn |
From: Jim C. <jc...@di...> - 2003-07-09 17:00:50
|
Mike Schilli wrote: >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. >> >> >> Youve implied that you want b.pm writing to b.log, irrespective of whether its being used by X.pl or Y.pl. This may be unwise; your logs could be incomprehensible if X and Y (or even X and X) are run simultaneously. You may find them more useful if; theyre keyed to the executable name, theyre datestamped, one log-file per run. (assuming 2 progs in under second is unlikely) the following does this - it extracts the logfile name from $0, so the same config can be used from all your tools. log4perl.appender.MainLog.filename = sub { \ my $n = $0; \ $n =~ s|.*/||; \ $n =~ s/(\.(t|pl))?$//; \ $d = strftime "$format", scalar localtime; return "./$n.$d.log";\ } You can play similar tricks in choosing which log-config file to load, based upon value of $0, or of cmdline option. >But after calling a->run() b->run() logs into a.log too. > > you might just raise level of the root logger, so it doesnt print anything, then have a-logger and b-logger be siblings, rather than one also being root logger. |
From: Vince V. <vi...@ly...> - 2003-07-15 05:27:18
|
Hello Mike, MS> The big problem with having libraries add their share to the L4P configuration MS> is that there's no easy way of preventing them from stepping on each MS> other's feet. In my situation all libs belong to one bigger SW and I did not even think about the problem, that they might 'step on each others feet'. But while thinking about reusable code I think it won't be easy to get loggers which don't mess up with others unless there is so. who controlls them. Well... I ain't got Ideas, sorry. Best regards, Vince mailto:vi...@ly... ----- Monday, July 14, 2003, 10:35:21 PM, you wrote: >> 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? MS> Sorry for the long wait, here's a couple of thoughts on this: MS> There's currently no way in Log::Log4perl to load more than one config file MS> or to append configuration statements to a loaded configuration. This could MS> be changed, however, if we find a proper way of dealing with the following MS> implications: MS> The big problem with having libraries add their share to the L4P configuration MS> is that there's no easy way of preventing them from stepping on each MS> other's feet. What if lib A defines an appender named "File" and lib B MS> defines a different appender under the same name? What if the main application MS> wants to take control over lib X's L4P configuration? How could lib X MS> possibly know what kind of application it is going to run in and what the MS> l4p configuration requirements are? MS> Ideas? 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/bulletproofapps1 MS> _______________________________________________ MS> log4perl-devel mailing list MS> log...@li... MS> https://lists.sourceforge.net/lists/listinfo/log4perl-devel MS> . |
From: Mike S. <log...@pe...> - 2003-07-15 17:56:16
|
On Tue, 15 Jul 2003, Vince Veggus wrote: > But while thinking about reusable code I think it won't be easy to get > loggers which don't mess up with others unless there is so. who > controlls them. There's Log4j's "logger repositories" which allow separation of different log4j setups, I'm currently evaluating on how to integrate them into Log::Log4perl. -- Mike Mike Schilli log...@pe... http://perlmeister.com http://log4perl.sourceforge.net |