Re: [log4perl-devel] Understanding the config

2008-05-19 Thread Bill Moseley
On Thu, May 15, 2008 at 11:01:35PM -0700, Mike Schilli wrote:
> 
> You need to call the appender's layout() method to set the layout, other
> than that, the code above looks ok to me at first glance. It's fairly
> unusual to use Perl code to init Log4perl, most of the time people
> either use easy_init() or init($conf_file).

The log4perl config is not that complex, but we do have a few
appenders.

The problem is the log4perl.conf file is part of the application (it's
in subversion with the rest of the code).  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.

I can see it would be handy to have a base config file and then be
able to "override" just parts of the config that are different.

-- 
Bill Moseley
[EMAIL PROTECTED]


-
This SF.net email is sponsored by: Microsoft 
Defy all challenges. Microsoft(R) Visual Studio 2008. 
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
log4perl-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/log4perl-devel


Re: [log4perl-devel] Understanding the config

2008-05-19 Thread Kevin M. Goess
>
> 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/vse012070mrt/direct/01/
___
log4perl-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/log4perl-devel