Hi,

this is now more a MooseX::Log::Log4perl related question. When you look at the perldoc of that package IMHO anything is said. You have to initialize the Log::Log4perl singleton before logging the first time. Example is given in the perldoc.

Init like

my $log4perl_conf = q( log4perl.logger=DEBUG, STRINGCOLLECTOR log4perl.appender.STRINGCOLLECTOR = Log::Log4perl::Appender::String log4perl.appender.STRINGCOLLECTOR.layout = Log::Log4perl::Layout::Patt +ernLayout log4perl.appender.STRINGCOLLECTOR.layout.ConversionPattern = %p:%d{ISO +8601}:myscript: %m%n ); Log::Log4perl->init( \$log4perl_conf );
before first usage.

UPDATE: As the doc says: You can get the logger instance with $self->logger. So later you should get the collected output with

my $appender = $self->logger->appender_by_name('STRINGCOLLECTOR'); my $string = ''; if($appender) { $string = $appender->string(); }

McA


In reply to Re^3: log4perl collecting (buffering) messages by McA
in thread log4perl collecting (buffering) messages by coke4all

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.