From: William M. <wi...@kn...> - 2003-09-24 22:40:15
|
Hi, I'm new to Log4perl but am looking forward to using such a well architected logging environment! I am in the process of inserting logging statements into an application that I run in mod_perl. During development, I use Apache::Reload to reload any modules which get updated. This technique appears to be causing my logger->info() statements to be reprocessed which is resulting in multiple messages being sent to my log file (one more for each time the module is reloaded). Since I go through many iterations of a module during development, this can quickly become a nuisance. I checked the archives of the list but could not find any similar discussions. Does anyone else use Log4perl in such an environment? Is this the expected behavior? Is there any way I can convince Log4perl not to continue appending messages when a module is reloaded? Thanks! William -- Knowmad Services Inc. http://www.knowmad.com |
From: Mike S. <msc...@ao...> - 2003-09-24 23:09:44
|
William McKee wrote: > I'm new to Log4perl but am looking forward to using such a well > architected logging environment! Thanks - of course this honor goes to Ceki who architected Log4j :). > I am in the process of inserting > logging statements into an application that I run in mod_perl. During > development, I use Apache::Reload to reload any modules which get > updated. I see ... in a persistent environment like modperl this will cause Log::Log4perl->init() to be called twice, which in the current release will create duped loggers. To alleviate the problem until it gets fixed (next release), just use Log::Log4perl->reset(); Log::Log4perl->init(...); in your application instead of just calling init(). Or, just call init() once at server startup and not during the reload. -- -- Mike Mike Schilli m...@pe... |
From: William M. <wi...@kn...> - 2003-09-24 23:24:03
|
Hi Mike, Thanks for the prompt reply! Indeed inserting the reset worked. I discovered that the behavior occurs each time I ran my subroutine, not just when Apache::Reload got called. Given your explanation, this behavior makes sense because I am calling init each time it is run. So the init function currently creates a new logger object, and I'm basically firing off new ones every time my script runs. It's like a giant fireworks show (which is also what my logs start to look like after several runs <g>). Regards, William -- Knowmad Services Inc. http://www.knowmad.com |
From: Kevin G. <ke...@go...> - 2003-09-25 00:05:22
|
William, if I'm understanding you correctly, you're calling Log4perl's init() function inside a subroutine, and calling it repeatedly? Log4perl works from singleton objects that are global to the entire interpreter (package globals), so each perl interpreter only needs to call init() once in its lifetime. Subsequent calls to get_logger('somecategory') retrieve the same loggers from the hoard of singletons. Does that make sense? William McKee wrote: > Hi Mike, > > Thanks for the prompt reply! Indeed inserting the reset worked. > > I discovered that the behavior occurs each time I ran my subroutine, not > just when Apache::Reload got called. Given your explanation, this > behavior makes sense because I am calling init each time it is run. > > So the init function currently creates a new logger object, and I'm > basically firing off new ones every time my script runs. It's like a > giant fireworks show (which is also what my logs start to look like > after several runs <g>). > > Regards, > William > -- Happy Trails . . . Kevin M. Goess (and Anne and Frank) 904 Carmel Ave. Albany, CA 94706 (510) 525-5217 |
From: William M. <wi...@kn...> - 2003-09-25 01:15:34
|
On Wed, Sep 24, 2003 at 05:04:20PM -0700, Kevin Goess wrote: > William, if I'm understanding you correctly, you're calling Log4perl's > init() function inside a subroutine, and calling it repeatedly? > Log4perl works from singleton objects that are global to the entire > interpreter (package globals), so each perl interpreter only needs to > call init() once in its lifetime. Subsequent calls to > get_logger('somecategory') retrieve the same loggers from the hoard of > singletons. > > Does that make sense? Yep. It's the persistant environment that's causing some confusion for me. I'm following the first example from your article (great job btw!) at Perl.com. I've revised my subroutine to test for an existing logger before calling init again. William -- Knowmad Services Inc. http://www.knowmad.com |