2

I'm using log4cplus in my project to do logging. I created logger.conf and I will load it in the beginning of my application.

Here is my logger.conf:

log4cplus.appender.Developer=log4cplus::RollingFileAppender
log4cplus.appender.Developer.DatePattern = ".yyyy-MM-dd"
log4cplus.appender.Developer.Schedule = HOURLY
log4cplus.appender.Developer.File=log/developer.log
log4cplus.appender.Developer.MaxFileSize=3MB
log4cplus.appender.Developer.MaxBackupIndex=10
log4cplus.appender.Developer.layout=log4cplus::PatternLayout
log4cplus.appender.Developer.layout.ContextPrinting=enabled
log4cplus.appender.Developer.layout.ConversionPattern=%D{%Y-%m-%d %H:%M:%S,%Q} [%t] %p - %m%n 
log4cplus.appender.Developer.Threshold=TRACE
log4cplus.logger.DEVELOPER=TRACE, Developer

And I will load my config file in my code like this:

QString log_path = qApp->applicationDirPath() + "/log";
QDir().mkpath(log_path);
PropertyConfigurator logger(L"configs/logger.conf", Logger::getDefaultHierarchy());
logger.configure();

As you can see, whenever my log reach 3MB, Log4Cplus makes a backup (developer.log.1 to developer.log.10).

How can I tell Log4Cplus to compress the back up it create (in my configuration file)?

Jamal
  • 763
  • 7
  • 22
  • 32
M.H.
  • 223
  • 3
  • 10
  • 23

1 Answers1

1

I'm not sure but I don't think you can specify that in the config file. One way would be to create your own appender, inheriting from RollingFileAppender and then add a compression step after the copy.

dutt
  • 7,909
  • 11
  • 52
  • 85
  • And how can i do that?! Is it possible i create my appender in config file or it have to be inside the code ?! – M.H. Nov 20 '13 at 10:33