log4j:ERROR setFile(null,true)调用失败

时间:2014-01-21 15:47:19

标签: tomcat log4j tomcat7 tomcat6

当我检查我的服务控制台时,我遇到了一些我的log4j错误。我的log4j在

之下
    log4j.rootLogger=INFO, R

#log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
#log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
#log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %-5p [%c{1}:%L] %m%n


log4j.appender.R = org.apache.log4j.RollingFileAppender 
log4j.appender.R.File = "DataSourceFactory.log" 
log4j.appender.R.Append = true 
log4j.appender.R.MaxFileSize=10MB 
log4j.appender.R.MaxBackupIndex=1000 
#log4j.appender.R.DatePattern = '.'yyy-MM-dd 
log4j.appender.R.layout = org.apache.log4j.PatternLayout 
log4j.appender.R.layout.ConversionPattern =%d{yyyy-MM-dd HH:mm:ss} %t/%c{1} [%p]

这是我的错误

 log4j:ERROR setFile(null,true) call failed.
jvm 1    | java.io.FileNotFoundException: /opt/igr-tomcat/logs/liferay.2014-01-21.log (Permission denied)
jvm 1    |      at java.io.FileOutputStream.open(Native Method)
jvm 1    |      at java.io.FileOutputStream.<init>(Unknown Source)
jvm 1    |      at java.io.FileOutputStream.<init>(Unknown Source)
jvm 1    |      at org.apache.log4j.FileAppender.setFile(FileAppender.java:294)
jvm 1    |      at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:165)
jvm 1    |      at org.apache.log4j.rolling.RollingFileAppender.activateOptions(RollingFileAppender.java:179)
jvm 1    |      at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:307)
jvm 1    |      at org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:295)
jvm 1    |      at org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:176)
jvm 1    |      at org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:191)
jvm 1    |      at org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:523)
jvm 1    |      at org.apache.log4j.xml.DOMConfigurator.parseRoot(DOMConfigurator.java:492)
jvm 1    |      at org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:1001)
jvm 1    |      at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:867)
jvm 1    |      at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:815)
jvm 1    |      at com.liferay.util.log4j.Log4JUtil.configureLog4J(Log4JUtil.java:113)
jvm 1    |      at com.liferay.util.log4j.Log4JUtil.configureLog4J(Log4JUtil.java:60)
jvm 1    |      at com.liferay.portal.util.InitUtil.init(InitUtil.java:100)
jvm 1    |      at com.liferay.portal.spring.context.PortalContextLoaderListener.contextInitialized(PortalContextLoaderListener.java:161)
jvm 1    |      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4887)
jvm 1    |      at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5381)
jvm 1    |      at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
jvm 1    |      at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
jvm 1    |      at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
jvm 1    |      at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
jvm 1    |      at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:657)
jvm 1    |      at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1636)
jvm 1    |      at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
jvm 1    |      at java.util.concurrent.FutureTask.run(Unknown Source)
jvm 1    |      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
jvm 1    |      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
jvm 1    |      at java.lang.Thread.run(Unknown Source)

我试图将tomcat作为服务器运行。如何摆脱错误。是我的log4j正确吗? 我真的很新,请有人帮忙。感谢

1 个答案:

答案 0 :(得分:1)

声明tomcat的用户无权写入/opt/igr-tomcat/logs/。使用chmod ...或所有者chown ...

更改此目录的权限