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.

In reply to Re: Log4Perl by tilly
in thread Log4Perl not changing to new log by set_uk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.