Hi all,
just got a new request for L4p and wanted to solicit your opinions:
Given is the following L4p setup, which logs messages >= WARN to
a file and messages >= ERROR to both a file and the screen:
use Log::Log4perl qw(get_logger);
my $conf = q(
log4perl.category.Bar.Twix = WARN, Logfile, Screen
# Appender for >= WARN
log4perl.appender.Logfile = Log::Log4perl::Appender::File
log4perl.appender.Logfile.Threshold = WARN
log4perl.appender.Logfile.filename = test.log
log4perl.appender.Logfile.layout = SimpleLayout
# Appender for >= ERROR
log4perl.appender.Screen = Log::Log4perl::Appender::Screen
log4perl.appender.Screen.Threshold = ERROR
log4perl.appender.Screen.layout = SimpleLayout
);
Log::Log4perl::init(\$conf);
my $logger = get_logger("Bar::Twix");
# Goes to Screen and File
$logger->error("Error Message");
# Goes to File
$logger->warn("Warning Message");
Now, if the script calls $logger->more_logging() (e.g. because there's been
a -v command line switch or similar), nothing will really change, because
the appender's thresholds will block the new INFO messages.
To have both appenders adjust their thresholds to a lower level, the
application has to find out which appenders there are, what their thresholds
are, and adjust them accordingly.
If we wanted to make this kind of adjustment really easy (just like
more_logging()), what's the best way? I'm envisioning something like
$logger->more_logging();
$logger->lower_appender_thresholds();
or even
$logger->more_logging({lower_appender_thresholds => 1});
to have the logger hunt down all appenders connected to it and lower
or bump up their thresholds.
What do you think, is this a case common enough to provide a convenience
function for it?
-- Mike
Mike Schilli
m...@pe...
|