Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I do it like this:

use Log::Log4perl; my $logfile = 'clean.log'; unlink $logfile; # ignore errors do { # Isolate # Log configuration. # If you go for interpolation, escape the {} in the pattern or use # different delimiters or something. my $lconf = q{ log4perl.logger = TRACE, ap1 log4perl.appender.ap1 = Log::Log4perl::Appender::File log4perl.appender.ap1.filename = } . $logfile . q' log4perl.appender.ap1.layout = Log::Log4perl::Layout::PatternLayou +t log4perl.appender.ap1.layout.ConversionPattern = %d{yyyyMMdd HH:mm +:ss.SSSS} %5p %F{1} %L: %m %n log4perl.appender.ap2 = Log::Log4perl::Appender::Screen log4perl.appender.ap2.layout = Log::Log4perl::Layout::PatternL +ayout log4perl.appender.ap2.layout.ConversionPattern = %d{yyyyMMdd H +H:mm:ss.SSSS} %5p %F{1} %L: %m %n '; # unclear, but this MIGHT mean something. Log::Log4perl::init ( \$lconf ) or die "Log init failed"; }; # Isolate my $logger = Log::Log4perl->get_logger('Test');
That is, by using substitution within the quoted string config.

You could also do it using function-call config, and possibly by doing a string config and then overriding that one thing with a function call, I believe, but I haven't done that, so I won't give you fake example code.

In reply to Re: log4Perl dynamic filename by dd-b
in thread log4Perl dynamic filename by fritz1968

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others meditating upon the Monastery: (7)
    As of 2017-12-11 21:31 GMT
    Find Nodes?
      Voting Booth?
      What programming language do you hate the most?

      Results (313 votes). Check out past polls.