Subject: | calling force_next_check() breaks periodical config check |
As documentation says:
If you have a somewhat long delay set between physical config file
checks or don't want to use the signal associated with the config file
watcher, you can trigger a configuration reload at the next possible
time by calling "Log::Log4perl::Config->watcher->force_next_check()".
But when you do that, the application no longer periodically checks for changes. I've attached a test script in which changing the configuration file (for example log layout) has absolutely no effect on the logger, while it should pick up the change after max 2 logging statements.
If you remove the
Log::Log4perl::Config->watcher->force_next_check();
line, it works as advertised and reacts to configuration file changes. It also reacts if you call force_next_check again manually (for example every 10th loop), so it seems the only thing broken is the periodical check.
Perl 5.10.1, Log4perl 1.49, Centos 6.9
Subject: | break_watcher.pl |
#!/bin/env perl
use FindBin qw/$Bin/;
use Log::Log4perl qw/get_logger/;
Log::Log4perl::init_and_watch("$Bin/test_logging.conf", 5);
Log::Log4perl::Config->watcher->force_next_check();
my $log = get_logger();
my $cnt = 0;
while (sleep 2) {
$log->info("while test");
}
Subject: | test_logging.conf |
log4perl.rootLogger = INFO, Screen
log4perl.appender.Screen = Log::Log4perl::Appender::Screen
log4perl.appender.Screen.stderr = 0
log4perl.appender.Screen.layout = Log::Log4perl::Layout::PatternLayout
log4perl.appender.Screen.layout.ConversionPattern = %p (%R) - %m%n