Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 .

like image 249
Shifat Avatar asked May 15 '16 08:05

Shifat


2 Answers

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.

like image 100
Krzysztof Krasoń Avatar answered Oct 18 '22 00:10

Krzysztof Krasoń


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

like image 1
Mushtaque Ahmed Avatar answered Oct 18 '22 00:10

Mushtaque Ahmed