perl 安装LOG4perl 模块
环境信息
ubuntu 12.04 64位 桌面版
Log-Log4perl 的介绍网址:http://search.cpan.org/~mschilli/Log-Log4perl-1.49/lib/Log/Log4perl.pm
下载链接
wget http://search.cpan.org/CPAN/authors/id/M/MS/MSCHILLI/Log-Log4perl-1.49.tar.gz
安装
perl Makefile.PL
make && make install
测试LOG4perl 模块的配置文件 log.conf
log4perl.category.Foo.Bar=DEBUG,Logfile,Screen
log4perl.rootLogger=DEBUG,Logfile,Screen log4perl.appender.Logfile=Log::Log4perl::Appender::File
log4perl.appender.Logfile.filename=\
sub { return &log4::set_log_name(); }
log4perl.appender.Logfile.layout=Log::Log4perl::Layout::PatternLayout
log4perl.appender.Logfile.layout.ConversionPattern =%d{yyyy/M/d HH:mm:ss} %F %L - %m%n log4perl.appender.Screen = Log::Log4perl::Appender::Screen
log4perl.appender.Screen.stderr =
log4perl.appender.Screen.layout = Log::Log4perl::Layout::PatternLayout
log4perl.appender.Screen.layout.ConversionPattern =%d{yyyy/M/d HH:mm:ss} %F %L - %m%n
测试test.pl 程序
#!/usr/bin/perl
package log4;
use strict;
use FindBin qw($Bin);
use lib "$Bin/lib";
print "$Bin\n";
use Log::Log4perl qw(get_logger);
my $log = get_logger(__PACKAGE__);
my $log_name="log4.log";
my $log_conf = "log.conf";
print "$log_conf\n"; # Check config every 60 secs
Log::Log4perl::init_and_watch($log_conf,); $log->debug("Debug message");
$log->info("Info message");
$log->error("Error message");
$log->info(&ping);
sub ping
{ my @ping=readpipe("ping -c 4 127.0.0.1");
return @ping;
}
sub set_log_name
{
return $log_name;
}
执行测试程序命令
perl test.pl
打印结果
log.conf
// :: test.pl - Debug message
// :: test.pl - Info message
// :: test.pl - Error message
// :: test.pl - PING 127.0.0.1 (127.0.0.1) () bytes of data.
bytes from 127.0.0.1: icmp_req= ttl= time=0.032 ms
bytes from 127.0.0.1: icmp_req= ttl= time=0.027 ms
bytes from 127.0.0.1: icmp_req= ttl= time=0.026 ms
bytes from 127.0.0.1: icmp_req= ttl= time=0.027 ms --- 127.0.0.1 ping statistics ---
packets transmitted, received, % packet loss, time 2999ms
rtt min/avg/max/mdev = 0.026/0.028/0.032/0.002 ms
并且日志文件 log4.log 内容如下
// :: test.pl - Debug message
// :: test.pl - Info message
// :: test.pl - Error message
// :: test.pl - PING 127.0.0.1 (127.0.0.1) () bytes of data.
bytes from 127.0.0.1: icmp_req= ttl= time=0.023 ms
bytes from 127.0.0.1: icmp_req= ttl= time=0.028 ms
bytes from 127.0.0.1: icmp_req= ttl= time=0.028 ms
bytes from 127.0.0.1: icmp_req= ttl= time=0.027 ms --- 127.0.0.1 ping statistics ---
packets transmitted, received, % packet loss, time 2999ms
rtt min/avg/max/mdev = 0.023/0.026/0.028/0.005 ms
perl 安装LOG4perl 模块的更多相关文章
- perl 安装 ZooKeeper模块
1072 ./configure --libdir=/usr/lib 1073 make 1074 make install 1075 cpan ZooKeeper [root@wx03 c]# pe ...
- Linux下安装Perl和Perl的DBI模块
今天在虚拟机测试shell脚本的时候,有些命令使用不了. 比如说 mysqlhotcopy ,它提示Perl的版本太低. 我用的 RedHat9 的Perl才5.8.0版本...(2002年以前的) ...
- 【Perl】如何安装Bioperl模块?
目录 失败尝试一:使用cpanm 失败尝试二:使用CPAN 成功尝试:直接conda安装bioperl 没有尝试:源码安装bioperl 生信软件绕不过Perl,Perl绕不过Bioperl.而Bio ...
- 配置perl-cgi的运行环境,由于Active Perl安装在d:\perl
Apache 1.3.22 for Win32+PHP 4.0.6+Active Perl 5.006001+Zend Optimizer v1.1.0+mod_gzip 1.3.19.1a+MySQ ...
- Python学习笔记十_模块、第三方模块安装、模块导入
一.模块.包 1.模块 模块实质上就是一个python文件.它是用来组织代码的,意思就是把python代码写到里面,文件名就是模块的名称,test.py test就是模块的名称 2.包 包,packa ...
- perl中一些模块的ubuntu中依赖包
GD 先更新系统中的依赖包: sudo apt-get update sudo apt-get upgrade 进入 cpan> install GD 会提示没有安装libgd模块. 所以,先需 ...
- Python学习之==>第三方模块的安装、模块导入
一.模块&包 1.模块 模块实质上就是一个Python文件,它是用来组织代码的.意思就是把Python代码写在里面,文件名就是模块的名称.例如:random.py,random就是模块的名称. ...
- 查看npm全局安装的模块
1.查看所有高级的npm moudles npm list --depth= 2.查看所有全局安装的模块 npm list --depth= -global
- 使用pip安装BeautifulSoup4模块
1.测试是否安装了BeautifulSoup4模块 import bs4 print bs4 执行报错说明没有安装该模块 Traceback (most recent call last): File ...
随机推荐
- 解决对象不支持“getElementsByClassName”属性或方法 ie兼容性
解决 IE 或者兼容模式不支持 document.getElementsByClassName() 的方法 自已实现document.getElementsByClassName(): 网页错 ...
- mongodb学习之:聚合
@font-face { font-family: "Times New Roman"; }@font-face { font-family: "宋体"; }p ...
- 配置tomcat,访问端口改为80
首先:找到tomcat的的config文件夹下的server.xml文件: 编辑server.xml 保存server.xml文件,重启tomcat服务器,即可. 亲测好使.
- android studio导入项目出现的奇葩错误
1.Error:(1, 0) Cause: com/android/build/gradle/AppPlugin : Unsupported major.minor version 52.0
- DHCP request error:Timed out waiting for dhcpcd to start【转】
本文转载自:http://blog.csdn.net/zvivi521/article/details/9166899 [init.svc.dhcpcd_eth0]: [stopped] I/Serv ...
- LightOJ1220 —— 质因数分解
题目链接:https://vjudge.net/problem/LightOJ-1220 1220 - Mysterious Bacteria PDF (English) Statistics ...
- Spring源码-加载和IOC部分
源代码和注释放在了github上,包括加载过程的注释和getBean部分的 地址: https://github.com/lvxingzhi/spring-framework-4.3.9-note.g ...
- AndroidManifest配置之uses-sdk
uses-sdk配置 uses-sdk用来设置app对android系统的兼容性.它包含三个可选的配置项,分别为android:minSdkVersion,android:targetSdkVersi ...
- (QA-LSTM)自然语言处理:智能问答 IBM 保险QA QA-LSTM 实现笔记.md
train集: 包含若干条与保险相关的问题,每一组问题对为一行,示意如下: 可分为四项,第三项为问题,第四项为答案: 1.build_vocab 统计训练集中出现的词,返回结果如下(一个包含3085个 ...
- [POI 2000] 病毒
[题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=2938 [算法] 首先建出给定字符串集的AC自动机 存在无限长的代码当且仅当 : AC ...