Log4j无法在webapp文件夹中找到日志文件:
在其配置文件下面:
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 :(得分:0)
看起来您的日志文件路径设置不正确和/或您没有访问它。 我建议将它指向一个可写的位置