linuxloggingubuntu-16.04log4cplus

log4cplus RollingFileAppender don't create new file


I using log4cplus in my project, the appender is RollingFileAppender , the problem is that when the size of the log file reach the MaxFileSize, then it don't create new log file and not rolling on the old file.my envirionment is Ubuntu 16.04.4 LTS, the version of log4cplus is 1.2.1.

my conf:

log4cplus.rootLogger=TRACE, ERROR,ROLLING_LOG_FILE

log4cplus.appender.ROLLING_LOG_FILE=log4cplus::RollingFileAppender
log4cplus.appender.ROLLING_LOG_FILE.Schedule=DAILY
log4cplus.appender.ROLLING_LOG_FILE.DatePattern=yyyy-MM-dd
log4cplus.appender.ROLLING_LOG_FILE.MaxFileSize=10MB
log4cplus.appender.ROLLING_LOG_FILE.MaxBackupIndex=10
log4cplus.appender.ROLLING_LOG_FILE.File=./info.log
log4cplus.appender.ROLLING_LOG_FILE.layout=log4cplus::PatternLayout
log4cplus.appender.ROLLING_LOG_FILE.layout.ConversionPattern=%D{[%m/%d/%y %H:%M:%S]} [IS] [%-25b:%-4L] %-5p %c{2} %%%x%% - %m%n
log4cplus.appender.ROLLING_LOG_FILE.filters.1=log4cplus::spi::LogLevelMatchFilter
log4cplus.appender.ROLLING_LOG_FILE.filters.1.LogLevelToMatch=INFO
log4cplus.appender.ROLLING_LOG_FILE.filters.1.AcceptOnMatch=true
log4cplus.appender.ROLLING_LOG_FILE.filters.2=log4cplus::spi::DenyAllFilter

log4cplus.appender.ERROR=log4cplus::RollingFileAppender
log4cplus.appender.ERROR.Schedule=DAILY
log4cplus.appender.ERROR.DatePattern=yyyy-MM-dd
log4cplus.appender.ERROR.MaxFileSize=100MB
log4cplus.appender.ERROR.MaxBackupIndex=10
log4cplus.appender.ERROR.File=./error.log
log4cplus.appender.ERROR.layout=log4cplus::PatternLayout
log4cplus.appender.ERROR.layout.ConversionPattern=%D{[%m/%d/%y %H:%M:%S]} [IS] [%-25b:%-4L] %-5p %c{2} %%%x%% - %m%n
log4cplus.appender.ERROR.filters.1=log4cplus::spi::LogLevelMatchFilter
log4cplus.appender.ERROR.filters.1.LogLevelToMatch=ERROR
log4cplus.appender.ERROR.filters.1.AcceptOnMatch=true
log4cplus.appender.ERROR.filters.2=log4cplus::spi::DenyAllFilter

log4cplus.appender.TRACE=log4cplus::RollingFileAppender
log4cplus.appender.TRACE.Schedule=DAILY
log4cplus.appender.TRACE.DatePattern=yyyy-MM-dd
log4cplus.appender.TRACE.MaxFileSize=1000MB
log4cplus.appender.TRACE.MaxBackupIndex=10
log4cplus.appender.TRACE.File=./data.log
log4cplus.appender.TRACE.layout=log4cplus::PatternLayout
log4cplus.appender.TRACE.layout.ConversionPattern=%D{[%m/%d/%y %H:%M:%S]} [IS] [%-25b:%-4L] %-5p %c{2} %%%x%% - %m%n
log4cplus.appender.TRACE.filters.1=log4cplus::spi::LogLevelMatchFilter
log4cplus.appender.TRACE.filters.1.LogLevelToMatch=TRACE
log4cplus.appender.TRACE.filters.1.AcceptOnMatch=true
log4cplus.appender.TRACE.filters.2=log4cplus::spi::DenyAllFilter

log size:

-rw-r--r-- 1 root root 11M Jul 7 10:51 info.log

Thanks!


Solution

  • It seems that you need absolute log path, not "./info.log".