OK, I've figure it out. the method: activateOption() must be called after setting. Codes as follows and sorry for buzzing.
Eric Liang wrote: > Hi, all > I'm just using log4cxx . It works well but the roll && backup functions. > > Here is the test codes: > <code> > #include <string> > #include <log4cxx/logger.h> > #include <log4cxx/patternlayout.h> > #include <log4cxx/rollingfileappender.h> > > int main() > { > > std::string loggerName="TESTER"; > log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger( loggerName ); > logger->setLevel(log4cxx::Level::getInfo()); > > log4cxx::PatternLayout *layout = new log4cxx::PatternLayout( "%d %r > [%t] %-5p - %m%n" ); > log4cxx::RollingFileAppender *appender = new > log4cxx::RollingFileAppender( layout, loggerName + ".log" ); > > appender->setMaximumFileSize( 10240 ); > appender->setBufferedIO( true ); > appender->setMaxBackupIndex( 100 ); > log4cxx::helpers::Pool p; appender->activateOptions( p ); > logger->addAppender( appender ); > int i = 10000; > while( i-- ) > LOG4CXX_INFO( logger, "Here is a test for file size." << i ); > > return 0; > > } > </code> > > The result of my test, the file : TESTER.log won't be rolled up until > it's size reach 10MB( not 10KB ) or so, while the backup files number > is still two. > Has anybody encountered this ? or have I missed something ? However , > any suggestions will be appreciated. > > Thanks in advance. > > Eric >
signature.asc
Description: OpenPGP digital signature