logging-log4cxx-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Liang <eric.l.2...@gmail.com>
Subject RollingFileAppender does't roll when file size reach the maximumfilesize.
Date Fri, 22 May 2009 10:06:18 GMT
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 );

    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


Mime
View raw message