Reputation: 367
i have create a config file for log4cplus and its works but MaxFileSize don't do anything so my files keep growing without taking in considaration my limit . this is my code :
### logs.properties
# root logger
log4cplus.rootLogger=INFO, Main
# specific logger
log4cplus.logger.myloggerINFO, Main
log4cplus.additivity.mylogger=false
# appender that automatically rolls files
log4cplus.appender.Main=log4cplus::DailyRollingFileAppender
log4cplus.appender.Main.Schedule=DAILY
log4cplus.appender.Main.File=mylogs.log
log4cplus.appender.Main.Append=true
log4cplus.appender.Main.MaxBackupIndex=100
log4cplus.appender.Main.MaxFileSize=100KB
log4cplus.appender.Main.layout=log4cplus::PatternLayout
log4cplus.appender.Main.layout.ConversionPattern=%D | %-5.5p | %-20.20c | %m|%n
log4cplus.logger.myLoggerName=DEBUG, R2
log4cplus.appender.R2=log4cplus::RollingFileAppender
log4cplus.appender.R2.File=logs/webaccess.log
log4cplus.appender.R2.Append=true
log4cplus.appender.R2.MaxBackupIndex=5
log4cplus.appender.R2.MaxFileSize=5KB
log4cplus.appender.R2.layout=log4cplus::PatternLayout
log4cplus.appender.R2.layout.ConversionPattern=%D | %-5.5p | %-20.20c | %m|%n
this is the example of list of files i get :
webaccess.log | 7kb even if max=5
mylogs.log | 0
mylogs.log.2012-11-26 | 1k
mylogs.log.2012-11-26.1 |1k
...
mylogs.log.2012-11-26.45 | 1k
he create new files even if max=100k
so if you see anything wrong please tell me thanks
Upvotes: 1
Views: 2915
Reputation: 18238
Log4cplus' DailyRollingFileAppender does not observe MaxFileSize
property. At the moment either you choose rolling log files by time or by size, you cannot have both at the same time.
EDIT 1:
The appender R2
does not work because there is a lower bound for the allowed MaxFileSize
value: const long MINIMUM_ROLLING_LOG_SIZE = 200*1024L;
This is 200 KiB. It in the log4cplus source from the start (or really long) and I have never felt a need to remove the limit.
Upvotes: 2