log4j:ERROR setFile(null,true) 调用 failed.java.io.FileNotFoundException:
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21597348/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
log4j:ERROR setFile(null,true) call failed.java.io.FileNotFoundException:
提问by pal
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:
下面是我的 log4j 配置文件:
#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)
硕士(项目名称)
Java Resource
WebContext
2.a -META-INF
2.b -WEB-INF
Java资源
网络上下文
2.a -元信息
2.b -WEB-INF
Please advise. Thanks
请指教。谢谢
采纳答案by cloudy
For a quick solution, set the absolute path.
要快速解决,请设置绝对路径。
回答by satender
Above error giving you a hint that the appender file is not reachable/readable with current user access.
上述错误提示您当前用户访问权限无法访问/读取appender文件。
in brief we can say that- without administrative rights, no one cannot write a file at C: drive
简而言之,我们可以说-没有管理权限,没有人不能在 C: 驱动器上写入文件
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.
作为快速补救措施,将 log4j.appender.FILE.File 设置更改为通过绝对路径指向文件,例如 /tmp/test.log。现在你不应该得到一个例外。