Interesting question. A memory reference doesn't come with a timestamp,
so the mechanism of watching it to see if it's changed since the last
time you looked at it would be considerably different from watching a file.
The whole point of the config file is to let users change the logging
behavior without having to do any programming. If you're that far
inside the guts of the process that it's easier generating a new string
reference than changing a file, you can just call init() again. The
attached seems to work, why don't you give that a shot?
Msc...@ao... wrote:
>
>
>
> ------------------------------------------------------------------------
>
> Subject:
> log4perl: reloading config info from a string
> From:
> Chris Hostetter <ho...@re...>
> Date:
> Mon, 16 Sep 2002 15:27:35 -0700 (PDT)
> To:
> Michael Schilli <log...@pe...>
>
>
> Hi there,
>
> I had a question regarding your article recent perl.com article...
> http://www.perl.com/pub/a/2002/09/11/log4perl.html
>
> You mention that...
>
> Or, if you store the configuration description in $string, then you can
> initialize it with
>
> Log::Log4perl->init(\$string);
>
> You can even have your application check the configuration file in
> regular intervals (this obviously works only with files, not with
> strings):
>
> Log::Log4perl->init_and_watch("eat.conf", 60);
>
> My question is: why not also make it work with "strings" ?
>
> If the init method could take a scalar ref and an interval, and derefrence
> that ref at regular intervals, people could write applications which kept
> their configuration info in memory and used whatever method they wanted to
> upate it "on the fly" (without updating a config file on disk).
>
> Even 'cooler' would be if you could pass init a code ref to be evaluated
> at regular intervals so people could have their configuration information
> come from anywhere they wanted ... but I suppose that could still be
> possible using tied variables if support was added for polling scalar
> refs at a regular basis.
>
> --
>
> -------------------------------------------------------------------
> "Oh, you're a tricky one." Chris M Hostetter
> -- Trisha Weir ho...@re...
>
>
--
Happy Trails . . .
Kevin M. Goess
(and Anne and Frank)
904 Carmel Ave.
Albany, CA 94706
(510) 525-5217
|