in reply to Re^2: log4perl collecting (buffering) messages
in thread log4perl collecting (buffering) messages
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
before first usage.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 );
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: log4perl collecting (buffering) messages
by coke4all (Novice) on Mar 14, 2013 at 11:44 UTC |