|
From: Marco B. <mar...@ri...> - 2004-07-28 12:18:28
|
Hi, I'm new into log4cpp (but I usually use log4j in java) and I'm simply
tring to log to rolling files. This is my properties file:
log4j.rootCategory=DEBUG, R
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=test.log
log4j.appender.R.MaxFileSize=1000KB
log4j.appender.R.MaxBackupIndex=10
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d %-5p %c - %m%n
And this is my code snipplet:
int main(int argc, char* argv[])
{
try {
std::string initFileName = "./log4cpp.conf";
log4cpp::PropertyConfigurator::configure(initFileName);
}
catch(log4cpp::ConfigureFailure& f) {
std::cout << "Configure Problem " << f.what() << std::endl;
return -1;
}
log4cpp::Category& log =
log4cpp::Category::getInstance(std::string("R"));
while (true){
log.error("error");
log.warn("warn");
log.info("info");
log.debug("debug");
}
log4cpp::Category::shutdown();
return 0;
}
I supposed it should create 10 log files with a size of 1MB named test.log ,
test.log.1 , test.log.2 etc. But when I run it, it creates only 2 log files
named foobar and foobar.1 with a size of 10 MB. What's wrong in my
properties file (the program seems to ignore File,MaxFileSize and
MaxBackupIndex fields)? It works ok if used with log4j, why not here?
Thanx for your help,
Marco
|