|
From: Mike S. <msc...@ao...> - 2004-01-06 17:12:39
|
Tony Bowden wrote on 1/6/2004, 3:16 AM:
> My guess would be that in my test I would tell log4perl to use a
> different
> method of logging that's easier to test. It's not quite the same, but
> it's probably good enough.
>
> Is this a sensible approach, or is there a better way? If it's sensible,
> where's the best place to hook in to do that?
Absolutely, that's the way to go -- changing where logged message of a
system are going is just a matter of configuring l4p.
Just use a Log::Log4perl::Appender::File appender or
Log::Log4perl::Appender::TestBuffer at initialization time. Something like:
use Log::Log4perl qw(:easy);
my $conf = q(
log4perl.category = DEBUG, Logfile
log4perl.appender.Logfile = Log::Log4perl::Appender::File
log4perl.appender.Logfile.filename = test.log
log4perl.appender.Logfile.layout = \
Log::Log4perl::Layout::PatternLayout
log4perl.appender.Logfile.layout.ConversionPattern = %d %F{1} %L> %m %n
);
Log::Log4perl::init(\$conf);
DEBUG "wibble";
--
-- Mike
Mike Schilli
m...@pe...
|