log4j:ERROR setFile(null,true) call failed.java.io.FileNotFoundException:

岁酱吖の 提交于 2021-01-27 06:45:42

问题


I'm getting the below error while compiling the application

log4j:ERROR setFile(null,true) call failed.java.io.FileNotFoundException:\gel\ms\ex\ms.log (The system cannot find the path specified)

Below is my log4j config file:

#root log level
log4j.rootCategory=debug, R
log4j.logger.java.sql=DEBUG
log4j.logger.com.ibatis=DEBUG

# First type of log, output to file
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=/gel/ms/ex/ms.log
log4j.appender.R.MaxFileSize=5000KB
log4j.appender.R.MaxBackupIndex=3
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d [%40c] %5p - %m%n

And my project folder hierachy

MS(Project Name)

  1. Java Resource

  2. WebContext

    2.a -META-INF

    2.b -WEB-INF

Please advise. Thanks


回答1:


For a quick solution, set the absolute path.




回答2:


Above error giving you a hint that the appender file is not reachable/readable with current user access.

in brief we can say that- without administrative rights, no one cannot write a file at C: drive

As a quick remedy, change the log4j.appender.FILE.File setting to point to file by absolute path, for example /tmp/test.log. Now You should not get an exception.



来源:https://stackoverflow.com/questions/21597348/log4jerror-setfilenull-true-call-failed-java-io-filenotfoundexception

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!