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 ...
随机推荐
- EasyDarwin开源流媒体社区视频教程
EasyDarwin开源社区出视频教程了,经过几个深夜的努力,终于将第一次课程的5个课时的视频教程录好<EasyDarwin开源流媒体服务器:编译.配置.部署>,EasyDarwin后面会 ...
- HLS切片机
参考: 1,linux下搭建生成HLS所需的.ts和.m3u8文件http://www.cnblogs.com/mystory/archive/2013/04/07/3006200.html2,iPh ...
- 相机标定过程(opencv) + matlab参数导入opencv + matlab标定和矫正
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 辛苦原创所得,转载请注明出处 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ...
- 代码空间项目 -- cookie的基本使用
cookie在日常开发b/s架构时候经常使用,可以在记住用户,方便自动登录,也可以记住用户的偏好并对应推送广告 下面说说开发时候的基本用法: 1.创建cookie//设置cookie,键值对形式Coo ...
- APP测试走过的那些坑
我现在的工作有一大部分也是app测试,虽然自己是app开发出身,但是在测试上还是跌入了很多大坑,毕竟二者还是有很大不同,所处的角度也是不一样的.而开发转测试中,我认为较难的也是一个角度的转换,以一个开 ...
- ffmpeg xcode 中的使用
最近比较闲,苦于ios设备上没有直接播放torrent 文件的软件,开始折腾了.找了不少资料有了思路.但是其中用到了ffmpeg 这个东西. ffmpeg 是通用的一个视频解决框架,用C语言编写,通用 ...
- centos 7 / 6 smokeping安装
官网 值得拥有:http://oss.oetiker.ch/smokeping/doc/reading.en.html 安装依赖包 1 2 yum -y install perl perl-Net-T ...
- IOS下WEBVIEW 的javascript数组与json定义 及交互
最近在折腾IOS新闻浏览客户端,当中需要用到webview传递JSON数据到IOS上,然后在IOS上解析.刚入门IOS不久,看了不少的书,但都是囫囵吞枣.在开发过程中,遇到不少问题.开发环境mac m ...
- JSON标准格式
标准JSON的合法符号:{(左大括号) }(右大括号) "(双引号) :(冒号) ,(逗号) [(左中括号) ](右中括号) JSON字符串:特殊字符可在字符前面加 \ 或使用 ...
- c# aop讲解
先说下场景,C#中为什么要使用Aop,而我又是在哪里使用Aop? 本人只是想拦截实体类的Set的方法,然后在Set之前,调用一下其它方法,把值赋给另一个对象. 而我做的都是在实体类的基类里处理: 比如 ...