Thanks for the suggestion, but there are no methods available on the $log object that will modify the appenders, only methods to adjust the logger itself.

I have however now found a solution, to set the SCREEN appender to threshold of 'debug' : $Log::Log4perl::Logger::APPENDER_BY_NAME{'LOGFILE'}->threshold('DEBUG')

This does work as I required.

I believe that the method : Log::Log4perl->appender_by_name('SCREEN')->threshold('DEBUG') amends the 'actual appender' - however because these appenders are 'wrapped' it needs to be the 'wrapper class' itself that needs adjusted, to give me the desired result.

I had achieved this initially by modifying the objects data directly using : ${$Log::Log4perl::Logger::APPENDER_BY_NAME{'SCREEN'}}{'level'} = 20000

This is what initially seemed to be suggested at : http://log4perl.sourceforge.net/releases/Log-Log4perl/docs/html/Log/Log4perl.html#356d5 : "The previously mentioned method appender_by_name() returns a referrence to the real appender object. If you want access to the wrapper class (e.g. if you want to modify the appender's threshold), use the hash $Log::Log4perl::Logger::APPENDER_BY_NAME{...} instead, which holds references all appender wrapper objects."

After re-reading a few times, Im now aware of the threshold method on the actual 'wrapper class' ( $Log::Log4perl::Logger::APPENDER_BY_NAME{'LOGFILE'} ) and can therefore also use the 'friendly name' ( ie DEBUG/TRACE/WARN ) rather than a numeric ( 30000/20000/5000 )

Hope someone also finds this useful !


In reply to Re^2: Log::Log4perl - changing an appenders threshold by arc444
in thread Log::Log4perl - changing an appenders threshold by arc444

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.