I am using log4cplus to write the logs of my program. However, seems the DailyRollingFileAppender doesn't work as I expected. The log file is not rolled at midnight. Instead, the file is rolled when the first log message is written after midnight. In my application, that "first message" of the new day could be several hours after midnight. But I need the log file to be rotated at 00:00 midnight exactly. Following is my configure file for log4cplus:
log4cplus.rootLogger=TRACE, ROLLING, STDOUT
log4cplus.appender.STDOUT=log4cplus::ConsoleAppender
log4cplus.appender.STDOUT.layout=log4cplus::PatternLayout
log4cplus.appender.STDOUT.layout.ConversionPattern=%D{%Y-%m-%d %H:%M:%S.%q} %-5p - %m [%l]%n
log4cplus.appender.ROLLING=log4cplus::DailyRollingFileAppender
log4cplus.appender.ROLLING.Schedule=DAILY
log4cplus.appender.ROLLING.File=/var/log/myprog/myprog1/ldapproxy
log4cplus.appender.ROLLING.Append=true
log4cplus.appender.ROLLING.DatePattern='.'yyyy-MM-dd
log4cplus.appender.ROLLING.layout=log4cplus::PatternLayout
log4cplus.appender.ROLLING.layout.ConversionPattern=[%T] %D{%Y-%m-%d %H:%M:%S.%q} %-5p - %m [%l]%n