Log4Perl的使用
#!/usr/bin/perl use Log::Log4perl qw(:easy); Log::Log4perl->easy_init($INFO); drink(); drink("Soda"); sub drink { my($what) = @_; my $logger = get_logger(); if (defined $what) { $logger->info("Drinking ", $what); } else { $logger->error("No drink defined"); } }
如果出现
error line=Can't locate Log/Log4perl.pm in @INC
下载Log-Log4perl-1.49.tar.gz
解压后执行
perl Makefile.PL
make && make install