Log4j日志文件错误FileNotFoundException [英] Log4j logfile error FileNotFoundException

查看:450
本文介绍了Log4j日志文件错误FileNotFoundException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Netbeans Java编写log4j日志文件.我成功地将日志文件写入C:\ tmp \ log.txt,但是由于某种原因,我没有权限将其写入项目的根目录:log.txt.

I am trying to write a log4j logfile using Netbeans Java. I succeded writing the log file to C:\tmp\log.txt , but for some reason i have no premission to write it at the root of my project : log.txt.

这是我的log4j.properties:

This is my log4j.properties:

log4j.rootLogger = all, FILE
# Define the file appender
log4j.appender.FILE=org.apache.log4j.FileAppender
log4j.appender.FILE.File=log.txt <- failes

# Define the layout for file appender
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.ConversionPattern=[%5p](%F:%L) %m%n
log4j.appender.FILE.Append=false

推荐答案

您尝试过这个吗:

log4j.appender.FILE.File=./log.txt

.代表当前文件夹(通常是项目根文件夹).也许将您设置的日志文件放置在驱动器的根目录中.

. represents the current folder (usually the project root folder). Maybe the log file that you set are placed somewhere in root of your drive.

此参考资料可能对您有用:

您的Log4j日志文件在哪里?

这篇关于Log4j日志文件错误FileNotFoundException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆