Log4j没有将日志文件写入文件,而是写入控制台。我搜索了很多资源(我认为这个问题已经存在),但无法找到解决方案。
Log4j 1.2.17版本
以下是我的log4j配置:
log4j.rootLogger = INFO,stdout log4j.rootCategory = INFO,stdout,File
log4j.appender.stdout = org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout = org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern =%d {ABSOLUTE}%5p%t %c {20}:%L - %m%n
log4j.category.org.springframework = ERROR log4j.category.org.springframework.beans.factory = ERROR log4j.category.com.mypackage = INFO log4j.logger.org.springframework = ERROR log4j.logger.org.hibernate = ERROR log4j.logger.org.hibernate.persister.entity = ERROR
log4j.appender.File = org.apache.log4j.rolling.RollingFileAppender log4j.appender.File.File = / TMP / mylog.log log4j.appender.File.ImmediateFlush =真 log4j.appender.File.threshold = INFO log4j.appender.File.Append = true log4j.appender.File.MaxFileSize = 10MB log4j.appender.File.MaxBackupIndex = 20 log4j.appender.File.layout = org.apache.log4j.PatternLayout log4j.appender.File.layout.ConversionPattern =%d {ABSOLUTE}%5p%t %c {2}:%L - %m%n log4j.appender.File.rollingPolicy = org.apache.log4j.rolling.TimeBasedRollingPolicy log4j.appender.File.rollingPolicy.FileNamePattern = / TMP / mylog%d.log log4j.appender.File.layout.ConversionPattern =%d {ABSOLUTE}%5p%t %c {2}:%L - %m%n
我确保我对我要写入的目录有权限。 有人可以帮帮我吗?
答案 0 :(得分:1)
请对配置文件进行以下更改。
{{1}}
希望这很好。