3

Using a log4cplus config file for a bash script that runs a dcmtk (DICOM toolkit) operation. Logging works, and creates a new log every minute that the script is running (per "minutely" in the config file). "minutely" is for testing purposes, where it will become daily once I know it works as expected. (I don't want to wait days to see if will rotate and delete)

The problem is with MaxBackupIndex set to 5. I've got 12 log files in the log dir. In reading the API documentation…

"This property limits how many backup files are kept per single logging period; e.g. how many log.2009-11-07.1, log.2009-11-07.2 etc. files are kept."

If I'm reading correctly, as long as there are five or fewer "dcmtk.log.2014-04-04-09-41" files, they will not be deleted….

Well of course there are fewer than 5, because I've configured it to create only one per minute regardless of size.

I would think that having "MaxBackupIndex = 5" would mean there would be a max of 5 log files period, not a max of 5 log files within the period specified by "Schedule." In the end, I want to be able to set the number of MaxBackupIndex to x, and only have x number of files….

Any help either understanding this or getting the rotation to actually have a max of 5 logs would be appreciated.

Here is my config file:

log4cplus.rootLogger = INFO, logfile
# log debug messages to a log file (with automatic rotation) 
log4cplus.appender.logfile = log4cplus::DailyRollingFileAppender
log4cplus.appender.logfile.File = /securerad/logs/dcmtk.log
log4cplus.appender.logfile.Append = true
log4cplus.appender.logfile.ImmediateFlush = true
log4cplus.appender.logfile.Schedule = minutely
log4cplus.appender.logfile.MaxBackupIndex = 5

Thanks --Rich

wilx
  • 17,697
  • 6
  • 59
  • 114
RichR
  • 395
  • 1
  • 4
  • 14

1 Answers1

0

"This property limits how many backup files are kept per single logging period; e.g. how many log.2009-11-07.1, log.2009-11-07.2 etc. files are kept."

This is simply the way it has always been. It is historical behaviour. I would suggest using just RollingFileAppender instead.

wilx
  • 17,697
  • 6
  • 59
  • 114