2017-05-17 112 views
2

私の春バージョンは4.2.5です。(org.springframework.web.util.Log4jConfigListener)は中止されました。 Spring4.xはLog4j2.xmlを使用する必要がありますか?log4j:ERROR setFile(null、true)呼び出しに失敗しました。

ここに私のコードです。 どこが間違っているのか分かりません。

のlog4j.xml

/src/main/resources/log4j.xml 

web.xmlの

<context-param> 
    <param-name>webAppRootKey</param-name> 
    <param-value>webapp.root</param-value> 
    </context-param> 
    <context-param> 
    <param-name>log4jConfigLocation</param-name> 
    <param-value>classpath:log4j.xml</param-value> 
    </context-param> 
    <listener> 
    <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> 
    </listener> 
    <listener> 
    <listener-class>org.springframework.web.util.WebAppRootListener</listener-class> 
    </listener> 

のlog4j.xml

<appender name="MANAGER-APPENDER" class="org.apache.log4j.DailyRollingFileAppender"> 
    <param name="File" value="${webapp.root}/resources/logs/manager.log" /> 
    <param name="Append" value="true" /> 
    <param name="encoding" value="UTF-8" /> 
    <param name="DatePattern" value="'.'yyyy-MM-dd'.log'" /> 
    <layout class="org.apache.log4j.PatternLayout"> 
     <param name="ConversionPattern" value="[%-5p] [%d{yyy/MM/dd HH:mm:ss} %c{2}] - %m%n" /> 
    </layout> 
</appender> 

ログファイルを見て、任意のヘルプは素晴らしいですし、時間を割いて

ERR [err] log4j:ERROR setFile(null,true) call failed. 
    ERR [err] java.io.FileNotFoundException: /resources/logs/manager.log (No such file or directory) 
    ERR [err] at java.io.FileOutputStream.open0(Native Method) 
    ERR [err] at java.io.FileOutputStream.<init>(Unknown Source) 
    ERR [err] at java.io.FileOutputStream.<init>(Unknown Source) 
    ERR [err] at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:165) 
    ERR [err] at org.apache.log4j.DailyRollingFileAppender.activateOptions(DailyRollingFileAppender.java:223) 
    ERR [err] at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:307) 
    ERR [err] at org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:295) 
    ERR [err] at org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:191) 
    ERR [err] at org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:523) 
    ERR [err] at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:872) 
    ERR [err] at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:778) 
    ERR [err] at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:526) 
    ERR [err] at org.apache.log4j.LogManager.<clinit>(LogManager.java:127) 
    ERR [err] at org.apache.log4j.Logger.getLogger(Logger.java:104) 
    ERR [err] at org.apache.commons.logging.impl.Log4JLogger.getLogger(Log4JLogger.java:262) 
    ERR [err] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    ERR [err] at org.apache.commons.logging.impl.LogFactoryImpl.createLogFromClass(LogFactoryImpl.java:1025) 
    ERR [err] at [internal classes] 
    ERR [err] at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:302) 
    ERR [err] at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107) 
    ERR [err] at com.ibm.ws.webcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:2420) 
    ERR [err] at [internal classes] 
    ERR [err] at com.ibm.ws.webcontainer.osgi.WebContainer.access$000(WebContainer.java:104) 
    ERR [err] at com.ibm.ws.webcontainer.osgi.WebContainer$2.run(WebContainer.java:870) 
    ERR [err] at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) 
    ERR [err] at java.util.concurrent.FutureTask.run(Unknown Source) 
    ERR [err] at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) 
    ERR [err] at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
    ERR [err] at java.lang.Thread.run(Unknown Source) 
    ERR [err] log4j:ERROR Either File or DatePattern options are not set for appender [MANAGER-APPENDER]. 

感謝。

答えて

0

/resources/logs/manager.log(そのようなファイルやディレクトリはありません)と同じです。

最も可能性の高い理由は、あなたがプログラムを実行するユーザーには/ resources/logsの権限がないため、log4jはファイルを作成できないということです。

+0

いいえ、それはあなたが言ったようです。 – Olivia

関連する問題