Shifat
Shifat

Reputation: 762

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

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 .

Upvotes: 9

Views: 25924

Answers (2)

Mushtaque Ahmed
Mushtaque Ahmed

Reputation: 303

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

Upvotes: 1

Krzysztof Krasoń
Krzysztof Krasoń

Reputation: 27466

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.

Upvotes: 15

Related Questions