我正在尝试向 Log4perl 记录器添加和删除一个简单的文件附加程序,但是会生成警告并且没有打印任何内容。这是我的代码:
use strict;
use warnings;
use Log::Log4perl qw(:easy);
Log::Log4perl->easy_init($DEBUG);
use Log::Log4perl::Appender::File;
my $app = Log::Log4perl::Appender::File->new(
filename => "C:/users/my name/Desktop/someFile.txt",
mode => 'clobber',
utf8 => 1,
);
# print "appender name is " . $app->name();
my $logger = get_logger();
$logger->add_appender($app);
INFO('info');
$logger->remove_appender($app->name);
文件“someFile.txt”已创建但为空。生成的警告是:
Odd number of elements in hash assignment at C:/strawberry/perl/site/lib/Log/Log4perl/Appender/File.pm line 223.
Use of uninitialized value in print at C:/strawberry/perl/site/lib/Log/Log4perl/Appender/File.pm line 245.
带有时间戳的“信息”也会打印到命令行。谁能看到我犯了什么错误?