log4j:WARN No such property [maxFileSize] in org.apache.log4j.DailyRollingFileAppender

孤街浪徒 提交于 2019-12-08 17:30:28

问题


Everything works just as fine. But showing this error.

My log4j.properties file like :

# Root logger option
log4j.rootLogger=DEBUG, stdout, file

# Redirect log messages to console
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p    %c{1}:%L - %m%n

# Redirect log messages to a log file, support file rolling.
log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
log4j.appender.myAppender.DatePattern='.'yyyy-MM-dd
log4j.appender.file.File=D:\\log4j-application.log
log4j.appender.file.MaxFileSize=5MB
log4j.appender.file.MaxBackupIndex=10
 log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

Thanks in advance. Just tell me how to do it. I just want log file on daily rolling .


回答1:


DailyRollingFileAppender doesn't support MaxFileSize, RollingFileAppender does.

DailyRollingFileAppender is for rolling files based on the date and time of the log entry, so if you want to use it you should remove the MaxFileSize property.




回答2:


I changed the code to

log4j.appender.FILE=org.apache.log4j.RollingFileAppender

from

log4j.appender.FILE=org.apache.log4j.FileAppender

and it worked fine in log4j.properties file



来源:https://stackoverflow.com/questions/37236288/log4jwarn-no-such-property-maxfilesize-in-org-apache-log4j-dailyrollingfileap

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