Subject: | new method of initializing fails with actual code refs |
I would expect the following code to work:
#!/usr/bin/env perl
use strict;
use warnings;
use Log::Log4perl;
Log::Log4perl->init({
'log4perl.rootLogger' => 'ALL, FILE',
'log4perl.appender.FILE' =>
'Log::Log4perl::Appender::File',
'log4perl.appender.FILE.filename' => sub { "test.log" },
'log4perl.appender.FILE.layout' => 'PatternLayout',
'log4perl.appender.FILE.layout.ConversionPattern' => '[%r] %F %L %c -
%m%n',
});
Log::Log4perl->get_logger->debug('Logger intialized');
open my $fh, '<', 'test.log';
warn join '', $fh;
But sadly it just doesn't. You must quote the subroutine into a string.