> > But, the application has to > run in different environments (development, testing, staging, > production) so we need slightly different configurations under each > environment. > > So, I was looking at having a single log4perl config and then using > environment-specific config files to alter the behavior. The log > message pattern might be the same under each mode, but the > destination file might be different or the "owner" of the file might > be different, for example. > > I have a way to handle this right now, but it just means I need > separate log4perl config files for each operating environment. So, I > end up duplicating the config for the majority of the log4perl config. >
Interesting. The way they've solved that problem where I work, for *all* config files, not just log4perl, is to start with a base config file in a template, and when the service is started up, munge the config file based on per-host values. Something like this: ---------------------- # the config file looks like this log4perl.appender.file.filename = {$logfile} log4perl.appender.file.owner = {$owner} ----------------------- # the per-host values are set up somewhere like this $hosts = { QA => { logfile => '/var/log/qa.out', owner => 'bob the tester', }, PROD => { logfile => '/var/log/prod.out', owner => 'jerry the sysadmin', }, } # a Text::Template might be filled in like this $this_host = 'QA'; $munged_config = $template->fill_in(HASH => $hosts{$this_host}, ...); # and now you're ready to init Log::Log4perl::config(\$munged_config); ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ log4perl-devel mailing list log4perl-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/log4perl-devel