|
From: Mike S. <msc...@ao...> - 2002-12-11 18:56:27
|
ke...@go... wrote:
> That looks like a good solution to me, anybody else have any thoughts?
>
That effectively works around the problem of having to retrieve the
appender by name and making sure it still exists due to config reloads
etc. ... I like it!
Maybe config values should be generally settable via callbacks into Perl?
--
-- Mike
Mike Schilli
log...@pe...
>
> Kai Poitschke wrote:
>
>> Hi,
>> how about a construct like this in the config file?
>>
>> log4perl.appender.File.filename = sub { return GetLogflleName(); }
>>
>> Kai
>>
>>
>> On Thursday 05 December 2002 20:20, Duncan Cameron wrote:
>>
>>> On 2002-12-03 Mike Schilli <msc...@ao...> wrote:
>>>
>>>> Hi there,
>>>>
>>>> Kai Poitschke has brought up an interestingfeature request: Suppose,
>>>> your application had a configuration "-l logfilename" option to
>>>> specify
>>>> the name of the log file to be used. Now, if you have an external
>>>> configuration file (as opposed to a string ref passed to init()), how
>>>> would you be able to adapt the config file setting in the code?
>>>>
>>>> He suggests to have init() overwrite certain properties of the config
>>>> file like in:
>>>>
>>>> Dump2OWH.conf:
>>>>
>>>> log4perl.category.Dump2OWH = INFO, File, Screen
>>>>
>>>> log4perl.appender.File = Log::Dispatch::File
>>>> log4perl.appender.File.filename = Dump2OWH.log
>>>> log4perl.appender.File.mode = write
>>>> log4perl.appender.File.layout =
>>>> Log::Log4perl::Layout::PatternLayout
>>>> log4perl.appender.File.layout.ConversionPattern = %d: %m%n
>>>>
>>>> log4perl.appender.Screen = Log::Dispatch::Screen
>>>> log4perl.appender.Screen.stderr = 0
>>>> log4perl.appender.Screen.layout =
>>>> Log::Log4perl::Layout::PatternLayout
>>>> log4perl.appender.Screen.layout.ConversionPattern = %-5p> %m%n
>>>>
>>>>
>>>> test.pl:
>>>> # Einstellungen z.B. aus Programmflags bestimmt
>>>> $more_conf = q(log4perl.appender.File.filename = test.log
>>>> log4perl.appender.File.mode = append);
>>>>
>>>> Log::Log4perl::init('Dump2OWH.conf', $more_conf);
>>>>
>>>>
>>>> I can see at least one other way to implement it: a
>>>> not-yet-implemented-in-Log4perl feature like variables in config files
>>>> (log4j has something like that but I don't think they can specify the
>>>> variable replacement values via code) and a mechanism to define the
>>>> placeholders in init(conf_file, key => value, key => value);
>>>>
>>>> Any other ideas? Sounds like a pretty useful feature to me.
>>>
>>>
>>> Initially I wondered why I couldn't do something like this:
>>>
>>> Log::Log4perl::init('Dump2OWH.conf');
>>> my $appender = get_appender('File');
>>> $appender->filename('test.log');
>>>
>>> but after investigating found that get_appender is part of the log4j
>>> API which hasn't been implemented, Log::Dispatch::File doesn't support
>>> get and set methods on its instance variables, and, more importantly,
>>> that the output file is opened as part of the creation of the
>>> appender during the init(), so it's then too late to change the file
>>> name.
>>>
>>> Regards,
>>> Duncan Cameron
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> -------------------------------------------------------
>>> This sf.net email is sponsored by:ThinkGeek
>>> Welcome to geek heaven.
>>> http://thinkgeek.com/sf
>>> _______________________________________________
>>> log4perl-devel mailing list
>>> log...@li...
>>> https://lists.sourceforge.net/lists/listinfo/log4perl-devel
>>
|