in reply to Log4Perl not changing to new log

Reading the documentation for Log::Log4perl, it seems that they strongly prefer using config files. And then you would switch the logging behaviour just by changing the config files.

If you don't like this answer, then the easiest thing to do is intercept all calls that initialize a logger and keep track of loggers automatically. When you need to reinitialize, you will then have that list and can walk it in an automated fashion. There are several ways to do this, but the one that I recommend is to rename your current Log4PerlInit methods to _Log4PerlInit and then somewhere high in your inheritance tree write the following (untested):

sub Log4PerlInit { my ($self, @args) = @_; # Is this is an instance or class method? I don't # know what you are doing, so I will support both. $used_loggers{ref($self) || $self} = 1; $self->Log4PerlInit(@args); }
And now you have a hash whose keys are all loggers that you have. Walk the keys of the hash and reset them.

Replies are listed 'Best First'.
Re: Re: Log4Perl
by set_uk (Pilgrim) on Oct 29, 2003 at 19:17 UTC
    Thanks.

    Only reason I went with coding in the definitions was because I missed the part in the config which stated you could call in perl subs to define the parameters of the logger.

    Might be quicker to just revert to config file setup and then reread it every time I have a job switch

    Thanks for your help