问题描述
Log4j在webapp文件夹中找不到日志文件:
在其配置文件下方:
Log4j can't find a log file in the webapp folder:
Below its configuration file:
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必须自动创建它.但它会显示错误日志:
Project is deployed at W:\Media\Projects\Eclipse projects\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\my_project_name
.Maybe I can't get a something but seems Log4j must create it automatically. But it prints error log:
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)
那我应该在哪里创建日志文件?
Where should I create my log file then?
推荐答案
好像您的日志文件路径未正确设置和/或您没有访问权限.我建议将其指向某个可写位置
Looks like your log file path is not setup properly and/or you don't have an acess to it.I suggest to point it to some writable location
这篇关于Log4j无法写入日志文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!