use Log::Log4perl qw(:easy);
Log::Log4perl->easy_init($DEBUG); //定义输出级别
Log::Log4perl::init("/path/log4perl.conf"); //定义配置文件
my $logger = Log::Log4perl->get_logger("eventname"); //定义时间名称
$logger->debug("string"); //日志输出级别
log4perl.conf:
log4j.rootLogger=DEBUG, stdout, R
log4j.appender.stdout=org.
apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p (%F:%L) - %m%n
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=/home/pplive/scripts/php/logs/release.log
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS}[%c][%p]%m%n