|
From: Kai P. <ka...@po...> - 2002-12-06 09:10:58
|
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
--
Finding out what goes on in the C.I.A. is like performing acupuncture
on a rock.
-- New York Times, Jan. 20, 1981
Unix, WinNT and MS-DOS. The Good, The Bad and The Ugly.
Kai Poitschke MailTo:kai[_at_]poitschke[_dot_]de
Date/Time: Fri Dec 6 10:06:05 MET 2002
|