2017-09-19 197 views
0

Log4j中無法找到在webapp文件夾中的日誌文件:
低於其配置文件:的Log4j不能寫入日誌文件

log4j.rootLogger=DEBUG, STDOUT, FILE 

log4j.appender.FILE=org.apache.log4j.RollingFileAppender 
log4j.appender.FILE.File=adminservtool.log 
log4j.appender.FILE.MaxFileSize=16MB 
log4j.appender.FILE.MaxBackupIndex=256 
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout 
log4j.appender.FILE.layout.conversionPattern=[%d{dd.MM.YYYY HH:mm:ss.SSS}] %5p [%t] - %m%n 

log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender 
log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout 
log4j.appender.STDOUT.layout.conversionPattern=[%d{dd.MM.YYYY HH:mm:ss.SSS}] %5p [%t] - %m%n 
log4j.appender.STDOUT.Encoding=UTF-8 

項目部署在W:\Media\Projects\Eclipse projects\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\my_project_name。 也許我不能得到一些東西,但似乎Log4j必須自動創建它。但它打印錯誤日誌:

log4j:ERROR setFile(null,true) call failed. 
java.io.FileNotFoundException: adminservtool.log (Отказано в доступе) //Access denied 
    at java.io.FileOutputStream.open(Native Method) 
    at java.io.FileOutputStream.<init>(Unknown Source) 
    at java.io.FileOutputStream.<init>(Unknown Source) 
    at org.apache.log4j.FileAppender.setFile(FileAppender.java:294) 
    at org.apache.log4j.RollingFileAppender.setFile(RollingFileAppender.java:207) 
    at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:165) 
    at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:307) 
    at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:172) 
    at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:104) 
    at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:842) 
    at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:768) 
    at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:648) 
    at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:514) 
    at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:580) 
    at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:526) 
    at org.apache.log4j.LogManager.<clinit>(LogManager.java:127) 
    at org.apache.log4j.Logger.getLogger(Logger.java:104) 
    at com.skat.smev.conviction.util.Config.<clinit>(Config.java:12) 
    at com.skat.smev.conviction.listener.SmevResultListener.initialize(SmevResultListener.java:26) 
    at com.skat.smev.conviction.listener.SmevResultListener.<init>(SmevResultListener.java:21) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) 
    at java.lang.reflect.Constructor.newInstance(Unknown Source) 
    at java.lang.Class.newInstance(Unknown Source) 
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:114) 
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5026) 
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5633) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145) 
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1694) 
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1684) 
    at java.util.concurrent.FutureTask.run(Unknown Source) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
    at java.lang.Thread.run(Unknown Source) 

我應該在哪裏創建我的日誌文件呢?

回答

0

看起來您的日誌文件路徑設置不正確和/或您沒有訪問它。 我建議把它指向一些可寫的位置