日期:2014-05-20  浏览次数:20871 次

log4j 我在log配置文件,提示SetFile错误。
这个是log4jconf.cfg文件。
log4j.rootLogger=info,   stdout

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout

#   Pattern   to   output   the   caller 's   file   name   and   line   number.
log4j.appender.stdout.layout.ConversionPattern=%5p   [%t]   (%F:%L)   -   %m%n

log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
log4j.appender.R.File=./logs/snmpMgrLog

log4j.appender.R2=org.apache.log4j.DailyRollingFileAppender
log4j.appender.R2.File=./logs/hdmsUserLog

log4j.appender.R3=org.apache.log4j.DailyRollingFileAppender
log4j.appender.R3.File=./logs/AlarmLog

log4j.appender.R4=org.apache.log4j.DailyRollingFileAppender
log4j.appender.R4.File=./logs/unSolved


log4j.appender.R5=org.apache.log4j.DailyRollingFileAppender
log4j.appender.R5.File=./logs/snoop


log4j.appender.R.DatePattern= '. 'yyyy-MM-dd
log4j.appender.R2.DatePattern= '. 'yyyy-MM-dd
log4j.appender.R3.DatePattern= '. 'yyyy-MM-dd
log4j.appender.R4.DatePattern= '. 'yyyy-MM-dd
#log4j.appender.R5.DatePattern= '. 'yyyy-MM-dd

log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R2.layout=org.apache.log4j.PatternLayout
log4j.appender.R3.layout=org.apache.log4j.PatternLayout
log4j.appender.R4.layout=org.apache.log4j.PatternLayout
log4j.appender.R5.layout=org.apache.log4j.PatternLayout

log4j.appender.R.layout.ConversionPattern=%d   %p   %t   %c   -   %m%n
log4j.appender.R2.layout.ConversionPattern=%d   -   %m%n
log4j.appender.R3.layout.ConversionPattern=%m%n
log4j.appender.R4.layout.ConversionPattern=%m%n
log4j.appender.R5.layout.ConversionPattern=%m%n

#   Print   only   messages   of   level   WARN   or   above   in   the   package   com.foo.
log4j.logger.cn.com.pbi.netmgr.local.content=info,   R
log4j.logger.cn.com.pbi.netmgr.local.resource=info,   R
log4j.logger.cn.com.pbi.netmgr.local.etc   =   info,   R2
log4j.logger.cn.com.pbi.netmgr.alarm.logging.saver.LogOutput     =   info,   R3
log4j.logger.cn.com.pbi.netmgr.web.morning.resource.MenuMgrBean   =info,   R5
log4j.logger.cn.com.pbi.netmgr.alarm.logging.saver.UnSolvedEventSaver     =   info,   stdout,R4


我启动服务器时,报错,我在   WEB-Inf下放置一个log文件夹,log4j应该是在配置时,自动生成一个snoop文件,但是他怎么说是空的呢.setFile(null,true)两个参数是什么意义呢,我启动的时候没有调用cn.com.pbi.netmgr.web.morning.resource.MenuMgrBean里的东西.开始setFile的东西肯定是为空的.可是我就是找不出什么问题.大虾救命啊
log4j:ERROR   setFile(null,true)   call   failed.
java.io.FileNotFoundException:   .\logs\snoop   (系统找不到指定的路径。)
at   java.io.FileOutputStream.openAppend(Native   Method)
at   java.io.FileOutputStream. <init> (Unknown   Source)
at   java.io.FileOutputStream. <init> (Unknown   Source)
at   org.apache.log4j.FileAppender.setFile(FileAppender.java:273)
at   org.apache.log4j.FileAppender.activateOptions(FileAppender.java:152)
at   org.apache.log4j.DailyRollingFileAppender.activateOptions(DailyRollingFileAppender.java:206)
at   org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:247)
at   org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:123)
at   org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:87)
at   org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:645)
at   org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:603)